blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
d17e5cec34bcfbfb62f0dfba05b9fb20561d0af1 | fwilde/pyadv2 | /Session 1/scripts/threading_test1.py | 1,194 | 4.125 | 4 | #!/usr/bin/python3
# importing the sys module to use command-line arguments
import sys
# importing the threading module
import threading
# importing the time module
import time
# define functions for threading
def calc_square(numbers):
for n in numbers:
time.sleep(1.1) #artificial time-delay
print('T... | true |
1cf173df814c029c4296ac46179f39afb9503c9c | Jarvis3198/Python-Training | /3.py | 595 | 4.15625 | 4 | """Write a program which will accept 4 digit binary numbers each separated by a comma as its input and then check whether they are divisible by 3 or not.
The numbers that are divisible by 3 are to be printed, separated by a comma.
Example
Suppose the following input is given to the program:
0011,0100,0101,1001
Then... | true |
133e1597e1b796ceea7a2fdb94c0d9cef2ef3f6a | samuvale95/challengeBigDataCDC | /src/database.py | 1,330 | 4.15625 | 4 | from abc import ABC, abstractmethod
class Database(ABC):
"""This class is a template to implement a real Database class
"""
def __init__(self, config_obj:dict):
"""Database constructor
Args:
config_obj (dict): configuration object depends on implementation
"""
... | true |
c21bcbbf149e950e178819c51af3e4c390b3646f | Grassjpg/Stay-Hydrated- | /main.py | 445 | 4.28125 | 4 | n = input("How Many Cups Of Water Have You Had Today? \n")
n = int(n)
if n >= 11 and n <= 17:
print(
"You Are Probably Hydrated. Good Job!"
)
elif n < 11:
print(
"You Should Drink More Water! The Average Adult Male Needs 15.5 Cups A Day! The Average Adult Women Needs At Least 11.5!"
)
e... | true |
637dbc048452729521d2d145b7bc6909674f64b6 | kozousps/IS211_Assignment6 | /conversions.py | 2,063 | 4.25 | 4 | def convertCelsiusToKelvin(celsius):
"""
Takes in a float representing a Celsius measurement,
and returns that temperature converted into Kelvins"
"""
if celsius < -273.15:
raise OutOfRangeError('Celsius must be more than -273.15')
else:
kelvin = celsius + 273.15
return k... | true |
055baa1485d41cb88c671270d535c5ff4525a005 | NunoSantos98/com404 | /1-basics/2-input/3-data-types/bot.py | 333 | 4.1875 | 4 | print("What is your name human?")
name=input()
print("How old are you (in years)?")
age=int(input())
print("How tall are you (in meters)?")
height=float(input())
print("How much do you weigh (in kilograms)?")
weigh=int(input())
bmi=weigh/(height*height)
print(name+" you are "+str(age)+" years old and your bmi is "... | true |
ca8477a1b99e8322ee3f4e4907637b451c5baa9f | NunoSantos98/com404 | /TCA2/q7.py | 770 | 4.1875 | 4 | word=input("Plese, enter a word: ")
nbr_dots=len(word)
print("\n1 Under - display the word with a line under it")
print("2 Over - display the word with a line over it")
print("3 Both - display the word in an underline and overline")
print("4 Grid - display the word in a grid that is n x n in size")
option=int(input(... | true |
3ccab97203a25637baa50f66324950c844404f00 | af-orozcog/Python3Programming | /Python functions,files and dictionaries/assesment1_2.py | 302 | 4.25 | 4 | """
We have provided a file called emotion_words.txt that contains lines of words that describe emotions.
Find the total number of words in the file and assign this value to the variable num_words.
"""
f = open("emotion_words.txt","r")
num_words = 0
for line in f:
num_words += len(line.split()) | true |
e86a80f67967723d7a3482c3f7264134fe86728e | udayshergill/Learning-to-Code | /numberlister.py | 603 | 4.1875 | 4 | import time
print("Hello I will list all the numbers before the number you give me\n")
time.sleep(1.25)
def numberlister(x):
x = int(x)
holder = x
while(x > 0):
x -= 1
print(x)
time.sleep(0.5)
reverse = input("Would you like to list the reverse order?\n")
if revers... | true |
7c73cae4c306caddf02ccfe4ed2725b855380be2 | fgokdata/PythonCodes | /assignment-11.py | 332 | 4.15625 | 4 | #Is it Prime Number
number = int(input("Please enter the number you want to learn whether is Prime Number or not\n"))
primekey = 0
for i in range(2,number):
if number % i == 0:
print("{} is not a Prime Number.".format(number))
primekey += 1
break
print((not primekey) * f"{number} is a Pri... | true |
4aef9bb06123dfe36419433bb496253f79a776f2 | bopopescu/Daffo | /Python/Classes and Objects/Simple_Class.py | 800 | 4.28125 | 4 | class Simple:
# defining the properties
x = 21
# defining the constructor : default constructor
#def __init__(self):
# defining the custom constructor
def __init__(self,name,age):
self.name = name
self.age = age
# defining extra methods : Getters and Setters
def get... | true |
633b4fbc31191f262f2db7bee5db2e11b102b548 | bopopescu/Daffo | /Python/CollectionsINPython/Dictionary.py | 1,378 | 4.25 | 4 | # Here in this file we are going to see the demo of the Dictionary Data Structure
# available in Python.
# Dictionary is a key-value paired data structure in python
# In other Programming languages, we can see Dicitionary as HashMap
# Dictionary is an unordered, mutable data structure
# we can create dicitonary by two ... | true |
d6cbf4b91e0fe55fa3f5051cb541741f1fab28d9 | Caitlin1798/CS-304 | /Project1/average.py | 573 | 4.1875 | 4 |
print ("Hello, how many grades will you be entering today?")
howManyGrades = int(input())
total= 0
totalGrade = 0
gradeList = []
for i in range(howManyGrades):
print("please enter grade " + str(i+1))
studentGrade = float(input())
gradeList.append(studentGrade)
total += studentGrade
average = tot... | true |
ac81f24842576e42a56a1b0502c0ff89a1a9241c | lyuka/data_structure_and_algorithm_using_python | /priorityq.py | 1,708 | 4.125 | 4 | # Implemenetion of the unbounded Priority Queue ADT using a Python list
# with new items appended to the end..
class PriorityQueue:
# Create an empty unbounded priority queue.
def __init__( self ):
self._qList = list()
# Returns True if the queue is empty.
def isEmpty( self ):
return l... | true |
ecb86c6eea73bff25c99719d56c5c040f056613d | antikytheraton/algorithms | /sorting/bubble_sort.py | 868 | 4.4375 | 4 | import random
random.seed(42)
# List to order
num_list = [i for i in range(10)]
random.shuffle(num_list)
# print(num_list)
def bubble_sort(shuffle_list):
'''
A simple exchange sort algorithm that works by
repeatedly stepping through the list to be
sorted, comparing each pair of adjacent items
and... | true |
a6f53dbcbfd6e04144b31624fd5f53f0298ac019 | Nyu10/02_Matrix | /matrix.py | 1,972 | 4.4375 | 4 | """
A matrix will be an N sized list of 4 element lists.
Each individual list will represent an [x, y, z, 1] point.
For multiplication purposes, consider the lists like so:
x0 x1 xn
y0 y1 yn
z0 z1 ... zn
1 1 1
"""
import math
#print the matrix such that it looks like
#the template in the top comm... | true |
2eb81444ed5a52955a63c438030b530634513726 | k-schmidt/Project_Euler | /Python/P001.py | 622 | 4.53125 | 5 | '''
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get
3, 5, 6, and 9. Ths sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
'''
from functools import partial
def multiple(denominator, numerator):
return numerator % denominator == 0
is_multiple3 =... | true |
843b1b6c2201ce5f7be75b444f059bfe27b697c1 | kswr/pyMegaCourse | /ws/archive/otr/Script.py | 361 | 4.21875 | 4 | print('Hey there')
#assigns String value to variable, than uses .replace method on variable and prints value (modified)
replaced='Ardit'.replace('A','O')
print(replaced)
#assigns various values to variables
currency=145
currency_today=100.5
currency1='nothing'
#you can't use numbers as variables name
pri... | true |
70fa3b32903c784764af00387b4ec1dac61ab4c4 | gauriguptaa/100-days-of-code | /day-2-python/day-2-2-exercise-2.py | 235 | 4.28125 | 4 | #Write a program that calculates the Body Mass Index (BMI) from a user's weight and height.
height = float(input("enter your height in m: "))
weight = float(input("enter your weight in kg: "))
BMI = int(weight/(height**2))
print(BMI)
| true |
23f2fc8e6d23d0aefab6b344e3e806949734feb0 | Timidger/Scripts | /Math/FibGen.py | 890 | 4.125 | 4 | def getInput():
while True:
try:
limit = input('Please input your Term limit:')
return (limit)
except:
'Please enter integers'
def fibSeq(limit):
sequence = [1,2]
while len(sequence) < limit:
sequence.append(sequence[-2] + sequence[-1])... | true |
3de54287a1b477ce6548aab6ee751e7f713e4510 | Battleroid/signature-data | /misc/neighbor.py | 1,828 | 4.4375 | 4 | import operator
class Neighbor(object):
"""Used for comparing and determining neighbors.
Used to compare against a base list of data against its relatives using
a maximum distance and given operation to determine if it is a neighbor to
the base observation.
Args:
data (List[int]): Li... | true |
84a190b417dc7dfd3cc6f397af0189d42ffe2093 | rafasolo/RockPaperScissors | /main.py | 1,074 | 4.3125 | 4 | # Define Functions Under This
import random
def RPS():
choices = ['rock', 'paper', 'scissors']
print("Rock, Paper, Scissors!")
guess = input("Enter your choice: ") # asks to enter choice in console
computer_guess = random.choice(choices) # picks a random choice from the list called choices
... | true |
bb362a4a55ccb5a5364517bc11dc82476972dc04 | jfriend08/practice | /numbers/isPrime_basic.py | 1,013 | 4.125 | 4 | '''
Primality Test | Set 1 (Introduction and School Method)
isPrime basic method
We can do following optimizations:
Instead of checking till n, we can check till sqrt(n) because a larger factor of n must
be a multiple of smaller factor that has been already checked.
The algorithm can be improved further by observing ... | true |
83fe25fbe1b1203bff620cc26e89b30bf5b8b203 | sanketvrd/practice-python-to-fluent | /fourth program.py | 246 | 4.25 | 4 | #program that takes input from an user and gives all the divisors
number= int(input("Enter the number to get all the divisors :"))
list = list(range(2,number+1))
for x in list:
if number%x ==0:
print("The divisors are:" + str(x)) | true |
430dcd178a44515c3e1541192d7ba783d7cbe496 | Caress87/TTA | /Q1.txt | 358 | 4.21875 | 4 | import random
# Gather the user's name and store as varible
MyName= input("Hello! What is your name?")
number = random.randint(1, 10)
# Display name and greet to user
print ( "Hello, " + MyName + " I'm thinking of a number between 1 and 10?")
guess = int(input("Take a guess:"))
if guess == 7:
print ... | true |
89b7f7fe8b096dfa690ee50585070a3ef18cb51b | happenz7/Game-of-Clue | /cardShow.py | 2,735 | 4.25 | 4 | from tkinter import *
from src.card import *
class cardShow:
def __init__(self, game):
self.game = game
self.window = Tk()
self.frame_a = Frame()
self.window.resizable(False, False)
self.l = []
self.createWindow()
# What this class should do:
# Show the c... | true |
a7cd2080f2ceb93bf254f219544e40b6db3bc995 | SatyaAchanta/PythonLearning | /PythonDS/lists/exercises.py | 1,701 | 4.34375 | 4 | import sys
# 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... | true |
2742ee33296afe7ec0041b19af88cfc33741bcea | JacobisBored/logit | /Week 1/roman_dictionary/roman_dictionary_solution.py | 1,553 | 4.53125 | 5 | """
Roman Dictionary
----------------
Mark Antony keeps a list of the people he knows in several dictionaries
based on their relationship to him::
friends = {'julius': '100 via apian', 'cleopatra': '000 pyramid parkway'}
romans = dict(brutus='234 via tratorium', cassius='111 aqueduct lane')
countrymen = d... | true |
e981ccdbdb8f9bc49386243c7ab22435cd4ebf1c | priyanshu3666/Python | /Smallest_number_among_3.py | 515 | 4.21875 | 4 | #Program started
'''The input should be enter by user
x,y,z are the number enter by user'''
x = int(input("Enter 1st number"))
y = int(input("Enter 2nd number"))
z = int(input("Enter 3rd number"))
if (x < y) and (x < z) : #logic for checking the smallest number
print("The smallest number among ",x,",",y,"... | true |
7de473fd00f99e29958905ded99bf3e1398ac28b | santosh-potu/python-test | /tp/list_tuple_dict.py | 1,026 | 4.1875 | 4 | list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']
print (list)
print (list[0])
print (list[1:3])
print (list[2:])
print (tinylist * 2)
print (list + tinylist)
print ("\n\ntuple")
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
tinytuple = (123, 'john')
print (tuple) # Prints complete list... | true |
328187c080efb87795959b99fc46777a5b76899e | kailash-manasarovar/GCSE_code | /algorithms/binary_search.py | 2,397 | 4.28125 | 4 | # MAJOR REQUIREMENT is that the list is SORTED
def binary_search(list_of_items, search_item):
# beginning_of_list points to the beginning_of_list item in the list
beginning_of_list = 0
# end_of_list points to the end_of_list item in the list
end_of_list = len(list_of_items) - 1
# we assume we have... | true |
b0d3e01754ae3a53c29ef504f4f29ebd61d2c2c3 | kailash-manasarovar/GCSE_code | /advanced_challenges/factorial.py | 687 | 4.21875 | 4 | # The Factorial of a positive integer, n, is defined as
# the product of the sequence n, n-1, n-2, ...1
# and the factorial of zero, 0, is defined as being 1.
# Solve this using both loops and recursion.
# for loop solution
# def factorial(n):
# factorial = 1
# for i in range(1, n+1):
# factorial = factor... | true |
17ef8848e4b3f5adbf2f049812d2f59ab3c16b27 | fafk/algorithms | /findMedianSortedArrays.py | 2,080 | 4.125 | 4 | """
Given two sorted arrays, find their median.
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two
sorted arrays.
Follow up: The overall run time complexity should be O(log (m+n)).
Example 1:
Input: nums1 = [1,3], nums2 = [2]
Output: 2.00000
Explanation: merged arra... | true |
d1d7047b553cabc45b11a3055c53a6a02a2e0351 | xili-h/PG | /ISU3U/python/Looping Assessment/Rock_Paper_Seissor.py | 1,762 | 4.125 | 4 | def main():
import random
money = 25
print('\nYou start with $25.')
print('Every game is worth a $5.\n')
while money >= 5:
computer_choice = random.choice(('rock','paper','scissors'))
user_choice = input('rock, paper or scissors? ').lower()
while (user_choice != 'rock' and... | true |
c8c56498e865d8aafabc02443e351d92e4cb73cd | expilu/LearnPython | /stringformatting.py | 426 | 4.28125 | 4 | name = 'John'
print("Hello, %s!" % name)
name = 'John'
age = 23
print("%s is %d years old." % (name, age))
mylist = [1,2,3]
print("A list: %s" % mylist)
#exercise
# You will need to write a format string which prints out the data using the following syntax: Hello John Doe. Your current balance is $53.44.
data = ("Jo... | true |
f026507c004dfe3ff843cafaf9733b6142949238 | arulp3/quizinPython | /quiz.py | 1,716 | 4.1875 | 4 | print('Welcome.')
points = 0
playing = input('Are you ready? Press Y for Yes and N for No ')
if playing == 'N':
quit()
elif playing == 'n':
quit()
else :
print('Welcome to quiz competition')
print('your score {}'.format(points))
#question one
answer = input('What is the capital of I... | true |
e8ab714b5d2bc26824197d50fcc98d31b407d12a | noahtigner/UO-ComputerScience-DataScience | /CIS 210 - CS I/Week 5/string_reverse.py | 1,868 | 4.21875 | 4 | """
string_reverse.py: Recursive implementation of string_reverse(input string)
Authors: Noah Tigner
CIS 210 assignment 5, part 1, Fall 2016.
"""
import argparse # Used in main program to get PIN code from command line
from test_harness import testEQ # Used in CIS 210 for test cases
## Constants used by this ... | true |
eb3d169a7b6535d9ae1704fc41a7645e1ad1bd43 | jondavid-black/javahelloworld | /src/primes.py | 734 | 4.15625 | 4 | # A school method based Python3 program
# to check if a number is prime
from time import perf_counter
# function check whether a number
# is prime or not
def isPrime(n):
# Corner case
if (n <= 1):
return False
# Check from 2 to n-1
for i in range(2, n):
if (n % i == 0):
... | true |
6451f13edbcf004d3a20abcd05297bb3167dbfe8 | acnorrisuk/pyscripts | /counter.py | 406 | 4.21875 | 4 | #range ( ) function
print("counting:")
for integer in range(11):
print(integer, end=" ")
print("Fives:")
for integer in range(0, 51, 5):
print(integer, end=" ")
print("Threes:")
for integer in range(0, 51, 3):
print(integer, end=" ")
print("Counting:")
for integer in range(10, -1, -1):
... | true |
c94686dd66d0425f0c4cfac712c31a755c0a2933 | ikhader/Programming | /python/mutable_immutable.py | 561 | 4.21875 | 4 |
#string is an immutable object; meaning object cannot be changed after its creation
#Example: string is an immutable; check for address "a" after re-assignment
a = 'corey'
print a
print "address of a is: {}".format(id(a))
a = 'John'
print a
print "address of a is: {}".format(id(a))
#a[0] = 'j' #this will THOROUGH e... | true |
4ac575807e41f5949a8ecffc477ffde8ef70c762 | aantu014/Python | /Learning Python/Python Basics/Hello World.py | 1,736 | 4.1875 | 4 | #Hello
def main():
print("Hello world")
f=0
print(f)
# Redclare variable
f="abc"
print(f)
#variables of different types cannot be combined
print("this is a string " + str(123))
if __name__ == "__main__":
main()
def somefucntion():
global d #Makes variable global
d="This is va... | true |
6e61ffc2b2e5a39e1876fd0a3272a1be7468d1a4 | kathcode/PyGame | /05_text_number.py | 1,238 | 4.15625 | 4 | # Import the pygame library
import pygame
# Initialize the game engine
pygame.init()
# Colors
BLACK = (0, 0, 0)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
RED = (255, 0, 0)
# Dimensions
dimensions = (600, 300)
screen = pygame.display.set_mode(dimensions)
# Window title
pygame.display.set_caption("Kath learning pyg... | true |
bb916c88f6039470ec446bcb269a1f4a0b31c649 | thirumurthis/pythonLearning | /BasicLessons/CalculatorExample.py | 1,017 | 4.1875 | 4 | useroption = ["A" , "a","S" ,"s" ,"M" ,"m", "D" , "d"]
result =0
while True:
print ("Enter options:")
print ("Option to add two numbers - A/a")
print ("Option to subtract two numbers - S/s")
print ("Option to multiply two numbers - M/m")
print ("Option to divide two numbers - D/d")
print ("Opti... | true |
3064984c868a28455ad237bb3df5f005341f6d1b | CptAwe/SoYouThinkYouCanCode | /Python/2_string_manipulation/stingsExample.py | 2,051 | 4.40625 | 4 | """
Simple example for manipulating strings.
Make this:
Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high. Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are!
Into this:
Twinkle, twinkle, little star,
How I wonder what you are!
Up above t... | true |
8d52d0d15dcc5cb9be9aa873d24d77850ed5a97a | halobrain/knode | /python/python/6-DataStructures/tuple/2-tuple.py | 712 | 4.15625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 19 23:28:16 2018
@author: star
"""
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )
tinytuple = (123, 'john')
print (tuple) # Prints complete list
print( tuple[0] ) # Prints first element of the list
print( tuple[1:3] ) # Prints ... | true |
1e4bc30ca2780c2310a8a51cb449b1ae0fafeeb5 | mihirnimgade/ParseMathString | /StringEvaluate.py | 698 | 4.21875 | 4 | import re
import sys
from MathematicalOperations import *
from HelperFunctions import *
string = sys.argv[1]
def StringCalculate(string):
string = EvaluateParentheses(string) # Calculates all the values inside the parentheses
operators = re.findall("[0-9]+([\*\-\+/]*)[0-9]+", string) # Finds ... | true |
cf7e9c6f2aa2b0b64bbabb533571d5283ba16828 | wayne-pham/pci-xpress | /main.py | 2,033 | 4.34375 | 4 | import sqlite3
from sqlite3 import Error
database = sqlite3.connect("pythonsqlite.db")
cursor = database.cursor()
############ QUERIES ############
def query(sqlCode):
cursor.execute(sqlCode)
result = cursor.fetchall()
for row in result:
print(row)
print("\n")
def query(queryTitle, sqlCode):
print(quer... | true |
849f74bb6bb3688713d99190c9b01c50763d27e6 | lieutenantjesus/sandbox | /CollatzFinal.py | 444 | 4.25 | 4 | #Collatzfinal
#function w/if
#error checking
#while OUTSIDE OF FUNCTION
def collatz(num):
if num % 2 == 0:
print(num // 2)
return(num // 2)
elif num % 2 != 0:
print((num * 3) + 1)
return (num * 3) + 1
try:
myNum = int(input('Please enter a number: '))
except ValueError:
... | true |
e9ea7b34a34a4688e3a7f6aee31bd7b2baf1007c | gregorysimpson13/leetcode | /daily_challenges/reconstruct_itenerary.py | 2,419 | 4.125 | 4 | # Reconstruct Itenerary
# Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.
# Note:
# If there are multiple valid itineraries, you sho... | true |
94a3ef378f7cee7d9d4bc5a26ae53f8741ba2107 | DevAVIJIT7/algo_programs_python | /sorting/insertion_sort.py | 622 | 4.3125 | 4 | /**
Program use for sorting array using insertion sort.
Write a method for moving array elements next position
if elements are greater than the given value.
Then call these methods while looping through array elements.
**/
def insert(array, right_index, value):
i = right_index
while(i >= 0 and array[i]... | true |
d683b319a3a1648ff1b791c1437043117f7dee2d | manufebie/python-driver-simulation | /driving_simulation.py | 1,405 | 4.25 | 4 | '''
Equations of Motion
-------------------
1) v = u + at
2) s = ut + 0.5at2
3) v2 = u2 + 2as
u: initial velocity(speed)
v: final velocity(final speed)
t: time
a: acceleration = rate of change of velocity
s: displacement(distance covered)
For constant speed
------------------
distance = speed * time
... | true |
5679ec2c95b8682709089c93b1c5b58d241935a4 | kailashmandal13/python-programming-joc-nptel | /oop/classmethod_staticmethods.py | 2,125 | 4.21875 | 4 | #class method and static methods in python
#the regular method automatically takes in the instance of a class as the first arguement and we can override this
class Employee:
#class varible for upgrading the pay
raise_amount = 1.04
#number of the employee
num_of_emp = 0
'''documentation string __... | true |
9e9a242fb149d9ad7bb8474610df1a428ff7f0f9 | Nahalius/PythonBasics | /Simple/loop1.py | 341 | 4.25 | 4 | # -*- coding: utf-8 -*-
userInput = input('Enter 1 or 2: ')
if userInput == "1":
print ("Ama zdrasti")
elif userInput == "2":
print ("Python Rocks!")
else:
print ("You did not enter a valid number")
print ("This is task A" if userInput == "1" else "This is task B")
#for Loop
message = "forLoop";
for i ... | true |
7aebf3d4a51476294d3ec1caa575aa3ffab85712 | rhj0970/C200-Intro-to-Computing-Python | /LabAssignments/Lab10/converge.py | 2,648 | 4.46875 | 4 | import numpy as np
#import matplotlib.pyplot as plt
#Bisection Method is a root finding algorithm like Newton's method - but instead it uses 2 endpoints to determine the root of a function
#Requires f(a) and f(b) to have different signs (+,-), which implies that the root is between them
#If the middle of a and b, f(c... | true |
a6d8b9bdfc83fde57a469e951188fa6a84bac5e4 | munyumunyu/Python-for-beginners | /docs/OOPS/static4.py | 690 | 4.15625 | 4 | #Accessing Static Variables
'''
Now that we have created static variables, we can access them using the Class name itself.
Static variable belong to the class and not an object.
Hence we don’t need self to access static variables.
'''
class Mobile:
discount = 50
def __init__(self, price, brand):
sel... | true |
f0e12f75bb341416e06b3ebf9db8f0ac433975d0 | munyumunyu/Python-for-beginners | /python-exercises/game_2.py | 749 | 4.15625 | 4 | # Its a simple rock paper scissor game that uses the random module to play instead of a human
from random import *
x = randint(1,3)
if x == 1:
computer = 'rock'
elif x == 2:
computer = 'scissor'
else:
computer = 'paper'
player_1 = input('What is your pick ')
if player_1 == computer:
print('Its a tie')
elif player_1... | true |
6ca3586339c5afb60237fdfc52fb26d6ea5db4d6 | JPLee01/pands-problems-2020 | /bmi.py | 481 | 4.28125 | 4 | #John Paul Lee
#Problem Sheet for Week 2 of Programming and Scripting
#Ask user to input their weight in kilograms
weight = float(input("Enter Weight in Kilograms: "))
#Ask user to input thier height in centimeters
height = float(input("Enter Height in Centimeters: "))
#BMI calaculated by dividing weight by height (... | true |
c8623969e4c242447b65ffa375a9d5202691e34b | EthanL0311/CS1 | /Finished Programs/cylinder.py | 214 | 4.28125 | 4 | #Gets radius and length
#Uses pi
radius1 = input("What is the radius of a cylinder. ")
length = input("What is the length of a cylinder. ")
pi = float("3.14159")
input("\n\nPress the enter key to exit.")
| true |
5c71dfc6e7ca2d3b4b07d467ef88e93a59bb1851 | Shrishti904/Officessignment2 | /Callbyrefrence.py | 752 | 4.15625 | 4 | # list with EVEN and ODD number
# print original list
# loop to traverse each element in the list
# and, remove elements
# which are EVEN (divisible by 2)
def Toremoveeven(List1):
for i in List1:
if(i%2 == 0):
List1.remove(i)
print("List after Removing eve... | true |
7467ef06b89e40fac0e2baea5e7a9cf28e855bc7 | kenbranson/KenPythonCodeExamples | /module_example.py | 1,445 | 4.4375 | 4 | def myFunction(a):
return 2*a
# here is a function with an example of a default value for a parameter
# weirdly, default values are like module static variables. The default is set the first time the function is called
# but if the value is changed (like adding to a list), on the next call the changed value is us... | true |
97a445813045953e9394dce3f35b71451186ddfc | Ajmalyousufz/my_python_projects | /use of break and continue.py | 221 | 4.1875 | 4 | # Here we look for the use of break and continue statements
print("\n USE OF BREAK AND CONTINUE STATEMENTS\n")
num = int(input("Enter a number"))
for x in range(num + 1):
if x == 5:
continue
print(x)
| true |
8ee30d73b9b5888f05e880cb58a346279eab5d5b | Ajmalyousufz/my_python_projects | /for whie loop.py | 325 | 4.1875 | 4 | print("This is testing of for while loop")
limit = input("\nEnter number loop limit\n")
limit = int(limit)
# while loop
# 1,2,3,4,...,limit
i = 0
while i < int(limit):
i = i + 1
print(i)
# for loop
# 2,4,6,....limit
print("\nPrinting even numbers using for loop\n")
for x in range(2, limit, 2):
prin... | true |
cd271779fc14122ef0b873456ee80171c2475937 | lakitu231/mit | /6-0001/ps1b.py | 2,174 | 4.59375 | 5 | # Saving, with a raise
portion_down_payment = 0.25
current_savings = 0
r = 0.04
annual_salary = float(input("Enter your annual salary: "))
portion_saved = float(input("Enter the percent of your salary to save, as a decimal: "))
total_cost = float(input("Enter the cost of your dream home: "))
semi_annual_... | true |
48caeb5c2765cd422e8abee643778f6527853f39 | tanyaapb03/practice--January | /Q9.py | 976 | 4.15625 | 4 | #Given an array of integers, find two numbers such that they add up to a specific target number.
#The function twoSum should return indices of the two numbers such that
# they add up to the target, where index1 must be less than index2.
# Please note that your returned answers (both index1 and index2) are not zero-ba... | true |
e1d06e234c57bd00c8e30ed32c3c99887af19e1d | PepSalehi/algorithms | /kalman-filter/kalman_filter.py | 2,559 | 4.15625 | 4 | #!/usr/bin/env python
"""Pseudo Python code for calculating the Kalman filter for learning."""
import numpy.random
import matplotlib.pyplot as plt
class KalmanFilter(object):
"""
Kalman filter for finding the true value of data comming iteratively.
Attributes
----------
estimate : list of float... | true |
ca76e6ba49ff0c9b0e87f273e99bcc9463e0957c | lindaperez/Python_Algorithms | /FileRecursion.py | 1,914 | 4.3125 | 4 | import os
l = []
def find_files(suffix, path):
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.
There are no limit to the depth of the subdirectories can be.
Args:
... | true |
7ce8bc249ef65a9121774c9f8365739104e0c33d | madigun697/prepare_coding_interview | /Section 06: Data Structures: Arrays/leetcode/longestWord.py | 1,132 | 4.125 | 4 | # https://coderbyte.com/information/Longest%20Word
# Have the function LongestWord(sen) take the sen parameter being passed and return the largest word in the string. If there are two or more words that are the same length, return the first word from the string with that length. Ignore punctuation and assume sen will n... | true |
ba2e4222191c84a40de88f449e4f871948ac6244 | uffermvg/Python | /SurfaceArea.py | 431 | 4.1875 | 4 |
# Finds the surface area of a cylinder
#
Diameter = int (input ("Diameter"))
Height = int (input ("Height"))
def SurfaceArea(Radius , Height):
import math
Radius = (Diameter / 2)
SArea = (2 * math.pi * (Radius ** 2) ) + (2 * math.pi * Radius * Height)
return (SArea)
print ("The Surface A... | true |
516b09204e0b785076f9e9de5da307b7b03bf8ff | Surendra-Orupalli/Python-Exercises-Practice-Solution_w3resource | /019_Numpy/002_Numpy Array/E6.py | 386 | 4.4375 | 4 | """
6. Write a Python program to reverse an array (first element becomes last). Go to the editor
Original array:
[12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37]
Reverse array:
[37 36 35 34 33 32 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12]
"""
import numpy as np
array =... | true |
5005f75beb1d11e5726c22aae95ef97e51f34004 | Surendra-Orupalli/Python-Exercises-Practice-Solution_w3resource | /020_Pandas/001_Pandas Data Series/E4.py | 318 | 4.125 | 4 | """
4. Write a Python program to get the largest integer smaller or equal to the division of the inputs. Go to the editor
Sample Series: [2, 4, 6, 8, 10], [1, 3, 5, 7, 9]
"""
import pandas as pd
ds1 = pd.Series([2, 4, 6, 8, 10])
ds2 = pd.Series([1, 3, 5, 7, 10])
print(ds1 == ds2)
print(ds1 < ds2)
print(ds1 > ds2)
| true |
0f4bdd0d7ff44d471ce6421d3986d83d99c1629a | sschwoch/class-work | /computepay2.py | 388 | 4.125 | 4 | hours = float(input('Enter hours worked: '))
try:
hours = float(hours)
except:
print('Error, please enter a numeric input')
rate = float(input('Pay rate : '))
try:
rate = float(rate)
except:
print('Error, please enter a numeric input')
if hours > 40:
pay = (hours - 40) * (rate * 1.5) + (40 * rate)
... | true |
a3dfd69670dda838a5f6c5095e294abf0aafb836 | 369geofreeman/MITx_6.00.1x | /algos/search/binary-search.py | 1,039 | 4.25 | 4 | # Binary Search
# DESCRIPTION:
# Example of Binary search using a list of the first 25 prime numbers where we find a prime by index.
# - For use with: sorted lists
# - How: Binary search works by reducing the list by half with every wrong guess. Every time we double the size of the array, we need at most one more gu... | true |
ae5dafa844204014e90f93816af381884ad3a32f | 369geofreeman/MITx_6.00.1x | /leetcode/problems/Running-Sum-of-1d-Array.py | 980 | 4.125 | 4 | # Running-Sum-of-1d-Array
# Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]).
#
# Return the running sum of nums.
#
#
#
# Example 1:
#
# Input: nums = [1,2,3,4]
# Output: [1,3,6,10]
# Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].
# Exam... | true |
be478a8dc54973be1671fbcdd092c437474f062d | 369geofreeman/MITx_6.00.1x | /leetcode/arrays/conclusion/Third-Maximum-Number.py | 1,025 | 4.28125 | 4 | # Third Maximum Number
# Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n).
#
# Example 1:
# Input: [3, 2, 1]
#
# Output: 1
#
# Explanation: The third maximum is 1.
# Example 2:
# Input: [1, 2]... | true |
666e013da80d8695c8333bae27b1d872f86c8955 | 369geofreeman/MITx_6.00.1x | /runestone/chapter-2/proper-python-class.py | 1,966 | 4.1875 | 4 | # Writing a proper Python class
# A class that works well in the Python ecosystem.
# Each class should have a docstring to provide some level of documentation on how to use the class.
#
# Each class should have a __str__ magic method to give it a meaninigful string representation.
#
# Each class should have a pro... | true |
7aca09c78618ae0b1aa19de616452a9e014a2a91 | 369geofreeman/MITx_6.00.1x | /codewars/Enumerable-Magic-30-Split-that-Array.py | 904 | 4.125 | 4 | #Enumerable Magic #30 - Split that Array!
# Create a method partition that accepts a list and a method/block. It should return two arrays: the first, with all the elements for which the given block returned true, and the second for the remaining elements.
#
# Here's a simple Ruby example:
#
# animals = ["cat", "dog"... | true |
172855fc938b79e8d401b4ff2c61922a708a260a | 369geofreeman/MITx_6.00.1x | /codewars/Building-Spheres.py | 1,620 | 4.25 | 4 | # Building Spheres
# Now that we have a Block let's move on to something slightly more complex a Sphere.
#
# #Arguments for the constructor
#
# radius -> integer or float (do not round it)
# mass -> integer or float (do not round it)
# #Methods to be defined
#
# get_radius() => radius of the Sphere (do not ... | true |
b35cc8005e4bb13c3914ac3bfbbc03817f74b04b | 369geofreeman/MITx_6.00.1x | /leetcode/problems/Cells-with-Odd-Values-in-a-Matrix.py | 1,450 | 4.1875 | 4 | # Cells with Odd Values in a Matrix
# Given n and m which are the dimensions of a matrix initialized by zeros and given an array indices where indices[i] = [ri, ci]. For each pair of [ri, ci] you have to increment all cells in row ri and column ci by 1.
#
# Return the number of cells with odd values in the matrix af... | true |
d5ee406f29a447a427c858f37ec709abdda79f07 | angelonuoha/Data-Structures-and-Algorithms-Problem-Sets | /P1/file_recursion.py | 1,960 | 4.46875 | 4 | import os
def find_files(suffix, path):
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.
There are no limit to the depth of the subdirectories can be.
Args:
suff... | true |
b9bd3889226a2949e5a563c82be21ec784bfd8db | AgentT30/InfyTq-Foundation_Courses | /DataStructures and Algorithms Using Python/Day 6/make_change.py | 1,031 | 4.21875 | 4 | def make_change(denomination_list, amount):
'''Remove pass and implement the Greedy approach to make the change for the amount using the currencies in the denomination list.
The function should return the total number of notes needed to make the change. If change cannot be obtained for the given amount, then re... | true |
a9243b7bbec2e13ab2a55f5f375c6cfed9f6c73c | AgentT30/InfyTq-Foundation_Courses | /DataStructures and Algorithms Using Python/Day 5/selection_sort.py | 775 | 4.15625 | 4 | def swap(num_list, first_index, second_index):
num_list[first_index], num_list[second_index] = num_list[second_index], num_list[first_index]
def find_next_min(num_list, start_index):
next_min = 0
temp = num_list[start_index]
for i in range(start_index, len(num_list)):
if num_list[i] < temp:
... | true |
74f6b7f63f40a08dec45808a12379109d8523f20 | rohantalavnekar/Python | /forloop.py | 666 | 4.59375 | 5 | # for loop
# The for loop in Python is used to iterate over a sequence, and in each iteration, we can access individual items of that sequence.
# Python sequences
text = "Python"
languages = ['English', 'French', 'German']
# Creating a for loop
color = {"yellow","blue","red","green","yellow"}
for x in color:
print... | true |
3e6861e65183560550aa7a9b0f4b226cf1ca45cd | rohantalavnekar/Python | /Data Structures/dictionaries.py | 2,609 | 4.6875 | 5 | # Dictionaries are used to store data values in key:value pairs.
# A dictionary is a collection which is unordered, changeable and does not allow duplicates.
# Dictionaries are written with curly brackets, and have keys and values.
# Create a dictionary
thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 1... | true |
524bd56f177c1ea6d1d3c3fce03ca6fb8aa3e943 | mouryat9/USTAssignments | /April 4/palindrome.py | 1,036 | 4.28125 | 4 | # function which return reverse of a string
def reverse(s):
return s[::-1]
def isPalindrome(s):
# Calling reverse function
rev = reverse(s)
# Checking if both string are equal or not
if (s == rev):
return True
return False
file= "#Python is an interpreted high level p... | true |
6ad82c2d23ef258a5ae99bbd49126f158abb29e8 | cameronpena03/HangmanGame | /hangmangame.py | 1,712 | 4.40625 | 4 | #creates a list of possible words
words=["hello","cameron","python","hangman"]
#imports the random function for python
import random
#lets the computer pick a random word from the list
secretword=random.choice(words)
#set dashes to be the same length as whatever word is randomly selected
dash="_" * len(secretword)
#gi... | true |
bde5870417d9f659ec3e644d222a372f31cbb34e | vkuzo/euler | /p1.py | 1,215 | 4.3125 | 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.
"""
import unittest
def sumOfConsInts(n):
"""
Retuns sum of consecutive integers from 1 to n
"""
return n * (n + 1) / 2
de... | true |
9821263ac940335572bc15bc788dd51d60632727 | vkuzo/euler | /p4.py | 1,526 | 4.4375 | 4 | """
A palindromic number reads the same both ways.
The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
Find the largest palindrome made from the product of two 3-digit numbers.
"""
from math import pow
import unittest
def isPalindrome(s):
"""
Returns True if s is a palindrome
""... | true |
712f3e445105c0669df8417316e91129e041f2ab | NinjagoJaden1/JadenProjects | /56.py | 387 | 4.25 | 4 | hours=int(input("Enter any positive integer for hours "))
minutes=int(input("Enter any positive integer for minutes "))
seconds=int(input("Enter any positive integer for seconds "))
def convert_to_seconds(hours, minutes, seconds) :
seconds1=60 * minutes
seconds2=3600 * hours
total= seconds+seconds2+seconds1... | true |
700f0e12a881f3e6efbecae54c7bea4cd67cce14 | nolenbelle/NEU-CS5001-Final-Project | /Shuffle.py | 1,647 | 4.15625 | 4 | '''
Proj - Memory Game
CS5001 Fall 2020
Nolen Belle Bryant
When creating a deck object, shuffle will be called to randomize the placement of the card objects
'''
import random
##
##def shuffle(file,cards):
## ''' Function: shuffle- shuffles the images displayed on the cards
... | true |
71e047e02d681fcca0037f48efc1788d6a5d655b | varenaggarwal/misc | /leetcode/firstBadVersion.py | 1,202 | 4.21875 | 4 | '''
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad.
Suppose you have n versions [1, 2, ..., n] an... | true |
7ddcb99b285a14f4db871df26aa5eafa5b5e97a6 | jahlela/calculator-1 | /arithmetic.py | 975 | 4.25 | 4 | def add(num1, num2):
""" Returns the sum of the inputs"""
return num1 + num2
def subtract(num1, num2):
"""Returns the result of subtracting the second number from the first"""
return num1 - num2
def multiply(num1, num2):
"""Returns the product of the inputs"""
return num1 * num2
def divide(num1, num... | true |
02c7cac8da572159a75fd05ba86493eddfd5f984 | emehrawn/mehran.github.io | /Python/Classes/classrect.py | 280 | 4.125 | 4 | #Write a Python class named Rectangle constructed by a length and width
#and a method which will compute the area of a rectangle.
class rectangle:
def dddd(self, l, b):
self.l=l
self.b=b
a=l*b
print(a)
print(rectangle().dddd(4,5)) | true |
ea017382b040c683bfb7b89e8a33142eb5df618a | emehrawn/mehran.github.io | /Python/Classes/CLASSES_IN_PYTHON_3.py | 947 | 4.375 | 4 | class vehicle:
def general_usuage(self):
print("General Use : Transpotation")
class Car(vehicle): #this is called inheratance, here we inherit the parent class Vehicle and Car here is derived class
def __init__(self):
self.wheels=4
self.roof = True
def specific_usuage(se... | true |
e3753514f9cf5030f364c6e00cb513a25bf8a473 | vitaliykornenko/DEV274x | /Module 2 Sequence Manipulation/Practicas/Part4__Replace Value (Examples and Task 1-2).py | 2,100 | 4.4375 | 4 | #----------------------------------------------Examples-------------------------------------------------------
# [ ] review and run example
# the list before Insert
party_list = ["Joana", "Alton", "Tobias"]
print("party_list before: ", party_list)
# the list after Insert
party_list[1] = "Colette"
print("party_list aft... | true |
4fd4d837e8392e28e741b5b8484697f7649fdf59 | vitaliykornenko/DEV274x | /Module 2 Sequence Manipulation/Practicas/Part3__List Append (Task 1-4).py | 1,778 | 4.5 | 4 | #Task 1 .append()
# Currency Values
# [ ] create a list of 3 or more currency denomination values, cur_values
# cur_values, contains values of coins and paper bills (.01, .05, etc.)
# [ ] print the list
cur_values=[.01, 0.5, 0.10, 0.2, 0.7]
print(cur_values)
# [ ] append an item to the list and print the list
cur_valu... | true |
0cb52d98730cb72ab99cec3fba08ba20d94d0c15 | romalagu92/Python-Basics | /9_list.py | 1,253 | 4.34375 | 4 | shopping_list = ["milk", "pasta", "spam"]
print()
print(["milk","pasta"][::2],"***")
print(list("milk")[::2],"** List **")
print()
# continue: skip everything after, and next iteration continues
# only easier to read
for item in shopping_list:
if item == "spam":
continue
print("Buy " + item)
print()... | true |
20dabba01afd83000357e3260256b3fce6df95ec | Siddiqui-code/Lab-Assignment-7 | /Problem2 - CheckRange.py | 248 | 4.15625 | 4 | # Nousheen Siddiqui
# Edited on 02/25/2021
# Function to check whether a number is within the range (1.10)
def given_range(a):
if a in range(1,10):
print("It is in range")
else:
print("It is not in range")
given_range(11) | true |
729cdb5506e70927d8bb03d9b360543c9ce61083 | prakharninja0927/akash-internship-tasks | /task 3/t9.py | 333 | 4.3125 | 4 | #Take a number check if a number is less than 100 or not.
# If it is less than 100 then check if it is odd or even.
num = int(input("enter number :"))
if num<100:
if num%2==0:
print("{} is even".format(num))
else:
print("{} is odd".format(num))
else:
print("{} is grater than 100"... | true |
8e2d651552e9b1af182ef12b8195cc0c6c3f9c55 | MounicaSubramanium/Python-Step-by-Step | /oops_concepts12_DunderMethods_OperatorOverriding.py | 1,949 | 4.46875 | 4 | """
The methods that starts with '__' and ends with '__' are called dunder methods.
__init__ is called a dunder init and it's a special method since it's a constructor
"""
class Employee:
no_of_leaves=116
def __init__(self,aname,aage,arole):
#Here aname,aage and arole are the ergume nts of the construc... | true |
1a7c42e563a7af25e413414487d21f793f230508 | MounicaSubramanium/Python-Step-by-Step | /oops_concepts11_Super_Overriding_In_Classes.py | 1,832 | 4.21875 | 4 | class A:
classvar1="I'm a variable in class A"
def __init__(self):
self.var1="I am inside class A's constructor"
self.classvar1="This is class A'S instance variable classvar1"
self.special="special"
class B(A):
classvar1 = "I'm a variable in Class B"
def __init__(self):... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.