blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
eb3fb66e3983c8ea0d131c308cd32b0ed8c30b0c | UnderGrounder96/mastering-python | /02. Built-in Data Structures/4.sets.py | 963 | 4.625 | 5 | # EXAMPLE 1
myset = set();
myset.add(1)
myset.add(2)
myset.add(3)
mylist = [1,2,3,4,5]
myset2 = set(mylist)
# EXAMPLE 2
numbers = [1, 1, 2, 2, 4, 3]
print(numbers)
# converting the list into a set
set_uniques = set(numbers)
print(set_uniques)
# defining a new set
set_new = { 1, 4}
set_new.add(5)
set_new.remove(5)
l... | true |
c30c0b73aa515d1541962322d6b33079008d2a66 | Efun/CyberPatriotTutoring | /practice/Archive_8-9_2020/practice_9_27_2020.py | 1,624 | 4.1875 | 4 | from classes.BankAccount import BankAccount
# test = BankAccount('a', 'a', 100)
# print(test.balance)
# write a list of 5 elements containing tennis player names
tennisPlayers = ["serena williams", "roger federer", "rafael nadal", "novak djokovic", "rod laver"]
#print the second element of this list
#print (tennisP... | true |
155359354b2395e4c1b887ad8cb8c9312cb3f0fc | FisicaComputacionalPrimavera2018/ArraysAndVectorOperations | /vectoroperationsUpdated.py | 1,620 | 4.28125 | 4 | import math
#### FUNCTIONS
# The name of the function is "norm"
# Input: array x
# Output: the norm of x
def norm(x):
tmp = 0
for v in x:
tmp += v*v
norm_x = math.sqrt(tmp)
return norm_x
def vectorSum(x, y):
#z = x + y This doesn't work for arrays!
# First we check if the dimensions of x and y
# ... | true |
77d3c7c625dc887ddc8aaa848f0d199fbfa1a06b | JinalShah2002/MLAlgorithms | /LinearRegression/Prof.py | 2,211 | 4.34375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author Jinal Shah
Suppose you are the CEO of a restaurant franchise and are
considering different cities for opening a new outlet.
The chain already has trucks in various cities and you have data for
profits and populations from the cities.You would like to use ... | true |
751f1777faad91870b7079238aa8d840848021b7 | prabhatpal77/Complete-core-python- | /typeconversion.py | 390 | 4.125 | 4 | #Type conversion function converse the data in the form of required format in the data is possible to convert..
a=input("enter int value")
print(type(a))
b=int(a)
print(type(b))
c=input("enter float value")
print(type(c))
d=float(c)
print(type(d))
i=input("enter complex value")
print(type(i))
j=complex(i)
print(type(j)... | true |
0f5463149ed49570c867f233e6dbc145da9104d6 | prabhatpal77/Complete-core-python- | /identityope.py | 470 | 4.125 | 4 | #Identity operators are used to compare the addresses of the objects which are pointed by the operators ..
#there are 2 identity operators.
# 1. is 2. is not
a=1000
b=2000
c=3000
d=3000
p=[10, 20, 30]
q=[40, 50, 60]
x=[70, 80, 90]
y=[70, 80, 90]
print(a==b)
print(a!=b)
print(a is b)
print(a is not b)
print(c==d)
print(... | true |
94492c43f4f858d9e46e6484a4faf4cb1585d487 | prabhatpal77/Complete-core-python- | /filehandl.py | 323 | 4.4375 | 4 | # Through the python program we can open the file, perform the operations on the file and we can close the file..
# 'r', 'w', 'a', 't', 'b', '+' for operations on file
# Open function opens the given file into the specified mode and crete file object..
# reading from file...
x=open("myfile.txt")
print(x.read())
x.close... | true |
cf89d81fa5fa2fc86a2770f9cf42954ffa049599 | suzibrix/lpthw | /ex4.py | 1,660 | 4.21875 | 4 | # This line assigns 100 to the variable "cars"
cars = 100
# This statement assigns the number "4.0" to the variable "space_in_car"
space_in_a_car = 4.0
# Assigns the number 30 to the variable "drivers"
drivers = 30
# Assigns the number 90 to the variable "passengers"
passengers = 90
# Assigns the difference of varia... | true |
8d33594f74c58174b463aba1f3b365e4ef01fd5e | micgainey/Towers-of-Hanoi | /towers_of_hanoi_count.py | 1,979 | 4.15625 | 4 | """
Towers of Hanoi rules
1. You can't place a larger disk onto a smaller disk.
2. Only 1 disk can be moved at a time.
Towers of Hanoi moves is:
2^n - 1
OR
2 * previous + 1
example with 3 disks
3 towers: A. B. C.
Starting point:
1
2
3
A B C
... | true |
a5305f23d0038814f95207a3dba6199913518cbd | thewchan/impractical_python | /ch4/storing_route_cipher_key.py | 1,387 | 4.25 | 4 | """
Pseudo-code:
ask for number of length of key
initiate defaultdict
for count in length of key
ask for column number store as temp1
ask for direction store as temp2
defaultdict[temp1] = temp2
"""
from collections import defaultdict
while True:
key_len = input("Enter length of key: ")
try:
... | true |
6a1716818b21e765ba02e275553467a060c21269 | Kids-Hack-Labs/Fall2020 | /Activities/Week02/Code/activity1_suggested_solution.py | 737 | 4.125 | 4 | """
Kids Hack Labs
Fall 2020 - Senior
Week 02: Python Review
Activity 1
"""
#Step 1: Function that takes 2 arguments and displays greater
def greater(num_a, num_b):
if num_a > num_b:
print(num_a, "is greater than", num_b)
else:
print(num_b, "is greater than", num_a)
#step 2: Inp... | true |
1c7b497ffce28f0a1f2faa790eca25693b2814c1 | Kids-Hack-Labs/Fall2020 | /Activities/Week04/Code/act2.py | 1,116 | 4.3125 | 4 | """
Kids Hack Labs
Fall 2020 - Senior
Week 04: Introduction to Classes
Activity 2
"""
#Suggested answer:
class Animal():
def __init__(self, _type, _name, _legs, _sound):
self.type = _type
self.name = _name
self.legs = int(_legs)
self.sound = _sound
def walk(self)... | true |
c58359a746beaaa275045aafa9d1509b028a2760 | Kids-Hack-Labs/Fall2020 | /Homework/W02/Code/w02_hw_suggested_solution.py | 1,213 | 4.125 | 4 | """
Kids Hack Labs
Fall 2020 - Senior
Week 02: Python Review
Homework: Number guessing game
"""
#Step 1: random module import
import random
#Step 2: application main entry point
def main():
#setup (steps 2.1 through 2.5)
random.seed()
tries = 5 #total tries granted
guesses = 0 #total ... | true |
5eb8e0b24c3f32f17ec1d13c07aee382aeef9a39 | himajasricherukuri/python | /src/listfunctions.py | 1,949 | 4.21875 | 4 | lucky_numbers = [4,8,15,16,23,42]
friends = ["kevin","karen","jim","oscar","toby"]
friends.extend(lucky_numbers)
print(friends)
# extend function allows you take a list and append it on another list
#append- adding individual elements
lucky_numbers = [4,8,15,16,23,42]
friends = ["kevin","karen","jim","oscar","toby"]
f... | true |
b33bd9fe0dffcc22d3f657b10d11d1aff016b5b1 | yourpalfranc/tstp | /14challenge-2.py | 671 | 4.21875 | 4 | ##Change the Square class so that when you print a square object, a message prints telling you the
##len of each of the four sides of the shape. For example, if you ceate a square with Square(29)
##and print it, Python should print 29 by 29 by 29 by 29.
class Square():
square_list = []
def __init__(self, ... | true |
e489a9c6d7e662cd125a74b2f014614bdc861a9f | yourpalfranc/tstp | /13challenge-2.py | 937 | 4.1875 | 4 | ##Define a method in your Square class called change_size that allows you to pass in a number
##that increases or decreases (if the number is negative) each side of a Square object by that
##number.
class Rectangle():
def __init__(self, width, length):
self.width = width
self.length = length
... | true |
1cdbf36cf05b93addd8e5797b82747e5448462f8 | druv022/Disease-Normalization-with-Graph-Embeddings | /nerds/util/file.py | 1,216 | 4.21875 | 4 | import shutil
from pathlib import Path
def mkdir(directory, parents=True):
""" Makes a directory after checking whether it already exists.
Parameters:
directory (str | Path): The name of the directory to be created.
parents (boolean): If True, then parent directories are created a... | true |
e5b94f0ba5cadbd496e8bf15318db7ae8f4d31cf | Abhiram-Agina/PythonProjects_Algebra | /CHAPTER10_ExponentsProperties.py | 1,776 | 4.25 | 4 | # Type in an Expression that includes exponents and I will give you an Answer
# Negative Exponents: Work in progress
SEEquations = input(" Type in a simple expression using exponents, 1 operator, and the same constant (i.e. 3^2 * 3^6) \n ")
terms2 = SEEquations.split(" ")
ExponentTerms = []
for item in terms2:
if... | true |
9e25339de670199da3cab9de8a98cc88c58cb5ca | jansenhillis/Python | /A004-python-functionsBasic2/functionsBasic2.py | 2,414 | 4.40625 | 4 | # 1. Countdown - Create a function that accepts a number as an input. Return a new list that counts down by one,
# from the number (as the 0th element) down to 0 (as the last element).
# Example: countdown(5) should return [5,4,3,2,1,0]
def countdown(seed):
seedList = []
for i in range(seed, -1, -1):
s... | true |
2e129574ad41492e099ab2181717ed8aeb79fb1f | simoonsaiyed/CS303 | /Payroll.py | 1,620 | 4.15625 | 4 | # Assignment 3: Payroll.py
# A program that prints out the Payroll dependent on inputs.
def calculate(worked, pay, fedtax, statetax):
worked = float(worked)
gross = worked * pay
fedwitholding = fedtax * gross
statewitholding = statetax * gross
total = statewitholding + fedwitholding
return worke... | true |
7b683b972accd14c161f79cb23a585863a9ab556 | rubayetalamnse/Basic-Python-Codes | /string-finction.py | 1,224 | 4.5625 | 5 | print(len("rubayet"))
#string functions------->>>>
passage = "nuclear energy provide zero carbon electricity, most reliable and cheap one. This energy is better than renewable energy! If we talk about wind power or solar or hydro, nuclear takes lowest place and produces maximum energy. And obviously we should come out... | true |
eeb24838ff1e76e6e73c80e79741e364e5716782 | rubayetalamnse/Basic-Python-Codes | /geeks-1.py | 353 | 4.15625 | 4 | #printing sum of two numbers
num1 = 10
num2 = 45
sum = num1+num2
print("Sum of {0} and {1} is : {2}".format(num1,num2,sum))
#printing sum of two decimal or float numbers
no1 = input("enter any decimal Number: ")
no2 = input("enter another decimal number: ")
sum2 = float(no1)+float(no2)
print("The sum of {0} and {1... | true |
8467ad15dcfeb454383e1ef26143328ccca9ec7d | rubayetalamnse/Basic-Python-Codes | /functions11.py | 2,640 | 4.40625 | 4 | """You're planning a vacation, and you need to decide which city you want to visit. You have shortlisted four cities and identified the return flight cost, daily hotel cost, and weekly car rental cost. While renting a car, you need to pay for entire weeks, even if you return the car sooner.
City Return Flight ($) Hote... | true |
933857731a1e75f757c5f57ef7913ca5585b0f7e | rubayetalamnse/Basic-Python-Codes | /celsius-farenheit.py | 598 | 4.3125 | 4 | #Write a Python program to convert temperatures to and from celsius, fahrenheit.
temperature = input("Input the temperature you like to convert? (e.g., 45F, 102C etc.) : ")
degree = int(temperature[0:-1])
temp = temperature[-1]
if temp.upper() == "F":
celsius_temp = float((degree - 32) * 5/9 )
print("The tem... | true |
94529887c259ec0c647cf90102487626a0b36fd5 | rubayetalamnse/Basic-Python-Codes | /for-break.py | 241 | 4.1875 | 4 | for i in range(5,20):
print(i)
if i==10:
break
#when i ==10, the loop ends. We see values from 5 to 10 in the terminal.
else:
print("as we used break at 10, 5 to 10 is printed. after that this else loop won't be printed") | true |
622019a68abba6e0c1d31bdec0ad3c2d7778809a | rubayetalamnse/Basic-Python-Codes | /functions6.py | 1,310 | 4.15625 | 4 | #If you borrow $100,000 using a 10-year loan with an interest rate of 9% per annum, what is the total amount you end up paying as interest?
import math
#for loan emi------------------------
loan = 100000
loan_duration = 10*12 #10 years
interest_rate = .09/12 #compounded monthly
#reusing our previous function to calc... | true |
c81b693f9dcca328b6d547ed885ed5403a266cbf | rubayetalamnse/Basic-Python-Codes | /q4b.py | 845 | 4.125 | 4 | #Use a for loop to display the type of each value stored against each key in person
person = {
"Name":"Rubayet",
"Age": 21,
"HasAndroidPhone": True
}
for i in range(len(person)):
print(type(person.keys()))
print(type(person.values()))
for value in person:
print(type(value))
for key in person... | true |
59a8c9b981bb0203fae5aabe709451ef4706a7c5 | edpretend/learn_python | /defs/def_txt.py | 1,264 | 4.34375 | 4 | """文本处理函数库"""
def watch_txt(filename):
"""watch txt and read"""
try:
with open(filename) as file_object:
contents = file_object.read()
except FileNotFoundError:
message = "Sorry, the file " + filename + " does not exist."
print(message)
else:
print(contents)
... | true |
86e7af0c89f72ae192f7c2e6936f7cbb28c47068 | Joyce-w/Python-practice | /09_is_palindrome/is_palindrome.py | 752 | 4.1875 | 4 | def is_palindrome(phrase):
"""Is phrase a palindrome?
Return True/False if phrase is a palindrome (same read backwards and
forwards).
>>> is_palindrome('tacocat')
True
>>> is_palindrome('noon')
True
>>> is_palindrome('robert')
False
Should ignore capi... | true |
a53af1d873b2238aa568577ae9ebd48bd7d8a846 | rgederin/python-sandbox | /python-code/src/collections/set.py | 2,859 | 4.46875 | 4 | x = {'foo', 'bar', 'baz', 'foo', 'qux', 'bar'}
print(type(x))
print(x)
x = set(['foo', 'bar', 'baz', 'foo', 'qux'])
print(type(x))
print(x)
x = set(('foo', 'bar', 'baz', 'foo', 'qux'))
print(type(x))
print(x)
_str = "quux"
print(list(_str))
print(set(_str))
# A set can be empty. However, recall that Python inte... | true |
113acba3954da223bf206b2f3c61df537db7f878 | syedareehaquasar/Python_Interview_prepration | /Hashing_Questions/is_disjoint.py | 982 | 4.21875 | 4 | Problem Statement
You have to implement the bool isDisjoint(int* arr1, int* arr2, int size1, int size2) function, which checks whether two given arrays are disjoint or not.
Two arrays are disjoint if there are no common elements between them. The assumption is that there are no duplicate elements in each array.
Inp... | true |
f4b23e71cb3395d3f90a8f823407ddea41724000 | shreyasandal05/HelloWorld | /utils.py | 203 | 4.1875 | 4 | def find_max(numbers):
"""This prints maximum number within a list"""
maximum = numbers[0]
for number in numbers:
if maximum < number:
maximum = number
print(maximum)
| true |
21334ff4ca556f71bdba054c54693575d5d94bfc | Yesid4Code/holbertonschool-higher_level_programming | /0x06-python-classes/6-square.py | 2,921 | 4.5625 | 5 | #!/usr/bin/python3
""" A Square class definition """
class Square:
""" Initialization of the class """
def __init__(self, size=0, position=(0, 0)):
""" Initialization of the class """
self.size = size
self.position = position
def area(self):
... | true |
168d8066d57bbf9e622187a32f93bd123531092d | AJKemps/cs-module-project-recursive-sorting | /src/sorting/sorting.py | 1,320 | 4.3125 | 4 | # TO-DO: complete the helper function below to merge 2 sorted arrays
def merge(left, right):
# elements = len(left) + len(right)
# merged_arr = [0] * elements
merged_arr = []
# Your code here
left_point = right_point = 0
while left_point < len(left) and right_point < len(right):
if l... | true |
5e653857300e785e7c2755977af5951cbd0bc909 | HeyMikeMarshall/GWARL-Data | /03-Python/2/Activities/01-Stu_QuickCheckup/Solved/quick_check_up.py | 483 | 4.15625 | 4 | # Print Hello User!
print("Hello User!")
# Take in User Input
hru = input("How are you doing today?")
# Respond Back with User Input
print(f"I am glad to hear you are {hru}.")
# Take in the User Age
age = int(input("If you don't mind my asking, how old are you?"))
# Respond Back with a statement based on age
if ... | true |
d8e26246147eeb15860e2946038dea1519814e13 | truongpt/warm_up | /practice/python/study/linked_list.py | 1,004 | 4.1875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def append(self, data):
new_node = Node(data)
if self.head is None:
self.head = new_node
return
... | true |
837417ff10a136800d60313bca2657459e48b71b | sailskisurf23/sidepeices | /prime.py | 556 | 4.28125 | 4 | #Ask user for Inputs
userinput1 = int(input("This program determines primality. Enter an integer greater than 0: "))
#Define function that returns divisors of a number
def divisor(number):
divisors = []
for x in range(1, (number+1)):
if number % x == 0:
divisors.append(x)
return divisor... | true |
bf34ef2231cd514deb40a267976b5b7ede184893 | sailskisurf23/sidepeices | /factorial.py | 337 | 4.21875 | 4 | uservar = int(input("Enter an integer you would like to factorialize: "))
def factorialize(var1):
"""Returns the factorial of var1"""
counter = 1
result = 1
while counter <= var1:
result = result * counter
counter = counter + 1
return result
print(str(uservar) +"! = " + str(factori... | true |
5e30f36955b95279a0e0c9cded56c35cf7d67184 | sailskisurf23/sidepeices | /dice.py | 2,879 | 4.34375 | 4 | #1. Write a function that rolls two sets of dice to model players playing a game with dice.
#It will accept two arguments, the number of dice to roll for the first player, and the number of dice to roll
#for the second player. Then, the function will do the following:
#* Model rolling the appropriate number of dice f... | true |
9fa447c3fae1328014bd7775bd7688bb16b2a180 | KSVarun/Coding-Challanges | /remove_consonents.py | 825 | 4.1875 | 4 | # Given a string s, remove all consonants and prints the string s that contains vowels only.
# Input: The first line of input contains integer T denoting the number of test cases. For each test case, we input a string.
# Output: For each test case, we get a string containing only vowels. If the string doesn't contain a... | true |
847252b2b65da4adf71fedb141400e8f74d97e5e | remon/pythonCodes | /python_bacics_101/Arithemtic_operators_en.py | 2,020 | 4.21875 | 4 | # Examples on how to uses Python Arithmetic Operators
'''
What is the operator in Python?
Operators are special symbols in Python that carry out arithmetic or logical computation.
The value that the operator operates on is called the operand.
for example: 2 + 3 = 5
Here, + is the operator that performs addition.
2 and... | true |
fb6b67ad09585fe97647f5fc40bf1934a4e7dfd7 | remon/pythonCodes | /Lists/List_Methods/append_en.py | 1,291 | 4.75 | 5 | #added by @Azharoo
#Python 3
"""
The append() method adds an item to the end of the list.
The item can be numbers, strings, another list, dictionary etc.
the append() method only modifies the original list. It doesn't return any value.
"""
#Example 1: Adding Element to a List
my_list = ['python', 'codes', 1, 2, 3]
... | true |
0a78a10b44750efbf098df50ab885e38eb12058e | remon/pythonCodes | /Functions/python_exmple_fibonacci_en.py | 641 | 4.375 | 4 | #this file print out the fibonacci of the function input
#importing numpy for execute math with lists
import numpy as np
#define the function that takes one input
def fibonacci_cube(num):
#define a list that contains 0 and 1 , because the fibonacci always starts with 0 and 1
lis = [0,1]
#this for loop take... | true |
591ce87b8211499434dc4f19086d6a8eb042f843 | remon/pythonCodes | /Functions/strip_en.py | 618 | 4.25 | 4 | #strip() returns a copy of the string
#in which all chars have been stripped
#from the beginning and the end of the string
#lstrip() removes leading characters (Left-strip)
#rstrip() removes trailing characters (Right-strip)
#Syntax
#str.strip([chars]);
#Example 1
#print Python a high level
str = "Python a high... | true |
57e7fdb1ff3591f58ec76cf85638980d3f5a6171 | remon/pythonCodes | /Lists/comprehensions_en.py | 1,012 | 4.5625 | 5 |
# Added by @ammarasmro
# Comprehensions are very convenient one-liners that allow a user to from a
# whole list or a dictionary easily
# One of the biggest benefits for comprehensions is that they are faster than
# a for-loop. As they allocate the necessary memory instead of appending an
# element with each cycle an... | true |
aa3f18d2d26c103253f0df89c11c30c5bd9a754e | vdn-projects/omnilytics-challenge | /read_print_data.py | 998 | 4.125 | 4 | import os
def is_float(obj):
"""
Check if object is float datatype or not
Args:
obj: input object in string
Returns:
True if it is float, else False
"""
try:
float(obj)
except ValueError:
return False
return True
if __name__=="__main__":
b... | true |
0858e00dbefe600268bf106ce92459396828b6f8 | laineyr19/MAGIC | /Week 3/text_based_adventure_game-2/game_02.py | 317 | 4.15625 | 4 | def main():
'''Getting your name'''
play_name=(raw_input("What's your name? > "))
play_age=(raw_input("enter your age? >"))
print ("hi"+" "+play_name)
result="my name is {name} and my age is {age}".format (name=play_name, age=play_age)
print(result)
if __name__ == '__main__':
main() | true |
7264c06c4327d762d4f072a4c903cc6fd79cf3c4 | krishnachouhan/calculator | /calculator/sum.py | 1,200 | 4.25 | 4 | # Sum Module
def sum(a, b, verbose=0):
'''
Writing this Sample doc. This is useful as when you type __doc(sum)__, this text is printed.
hence its a good practice to use this.
Here,
- parameters are to be explained.
- return values are to be explained.
- finally, dependencies ar... | true |
ee26f9872314401c7e376ac3018ef80dd5f23e58 | agandhasiri/Python-OOP | /program 4 Contest problems/everywhere.py | 996 | 4.15625 | 4 | Tests = int(input()) # no of test cases
len_list=[] # for length of each test case list with distinct names
for v in range(Tests): # a loop for every test case
n = int(input()) # no of work trips for each test case
list = [] ... | true |
218275d05a30d062ce99d9dd2f4cb2dea08523ca | xhemilefr/ventureup-python | /exercis5.1.py | 314 | 4.21875 | 4 | def reverse_string(string):
reversed_string = ""
for x in string:
reversed_string = x + reversed_string
return reversed_string
def check_palindrome(string):
temp = string.lower()
if temp == reverse_string(temp):
return True
return False
print(check_palindrome("Pasddsap")) | true |
0b8a3bfb2f1514d77b83bf94c59fefb20f1b5bd8 | mabbott2011/PythonCrash | /conditionals.py | 536 | 4.125 | 4 | # Conditionals
x = 4
#basic if
if x < 6:
print('This is true')
#basic If Else
y = 1
if y > 6:
print("This is true")
else:
print("This is false")
# Elif
color = 'red'
#color = 'blue'
#color = 'purple'
if color == 'red':
print('Color is red')
elif color == 'blue':
print('Color is blue')
else:
... | true |
63b4bdc7b80b17cd676b6c404c15a9ccb27f6d7e | ADcadia/py-calc | /coin-toss-calculator.py | 474 | 4.125 | 4 | # Enter the number of times you will toss the coin.
import random
def tossCoin():
num = random.randint(0, 1)
if num == 0:
return "Heads"
else:
return "Tails"
timesToToss = int(input("How many times will you toss the coin? \n"))
headsCounter = 0
tailsCounter = 0
for i in range(timesToToss):
if tossC... | true |
8c396abb6742f4e88cd68d47c057420fb5f3f253 | stoneboyindc/udacity | /P1/problem_2.py | 1,862 | 4.4375 | 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:
... | true |
b9d3484d14d0a0148a32d94715c1a30009ce3b3f | Rohitthapliyal/Python | /Python_basics/14.py | 280 | 4.15625 | 4 | import math
class Power:
x=int(input("enter any number:\n"))
y=int(input("enter base:\n"))
def show(ob):
ob.power=math.pow(ob.x*ob.y)
def output(ob):
print("power of the number is=",ob.power)
obj=Power()
obj.show()
obj.output()
| true |
c2c4f82acaa1cfa7cc082ddcdf5819a21d64f3fd | BadrChoujai/hacker-rank-solutions | /Python/13_Regex and Parsing/Re.findall() & Re.finditer().py | 1,211 | 4.125 | 4 | # Problem Link: https://www.hackerrank.com/challenges/re-findall-re-finditer/problem
# ----------------------------------------------------------------------------------
import re
m = re.findall(r'(?i)(?<=[^aeiou])[aeiou]{2,}(?=[^aeiou])', input())
if len(m) > 0:
print(*m, sep = '\n')
else:
print('-1')
... | true |
2ecded57167e4ff843aea14dcc97e141de899a38 | Sunil-Archive-Projects/Python-Experiments | /Python_Basics/classes.py | 370 | 4.1875 | 4 | #defining classes
class myClass():
def firstMethod(self):
#self refers to itself
print("First Method")
def secondMethod(self,str):
#self refers to itself
print "Second Method",str
#defining subclasses
# subClass inherits superClass myClass
class subClass(myClass):
x=0
def main():
obj=subClass()
obj.... | true |
063d16a81a5348f33bc809d857d7ad71d16ee58c | elmasria/mini-flow | /src/linear.py | 689 | 4.25 | 4 | from neuron import Neuron
class Linear(Neuron):
def __init__(self, inputs, weights, bias):
Neuron.__init__(self, inputs)
# NOTE: The weights and bias properties here are not
# numbers, but rather references to other neurons.
# The weight and bias values are stored within the
... | true |
bac53da6089ab51d4d094411fdcbc2a9741a50c4 | schnitzlMan/ProjectEuler | /Problem19/Problem19.py | 1,400 | 4.125 | 4 | # strategy -
#count all the days - approximately 100 * 365.25 - not too large.
#keep track of the month to add correctly
#devide the day by %7 - if no rest, sunday if you counted correctly
#count the numbers of sundays
#months = {"jan": 31, "feb": 28, "mar":31, "apr":30, "may":31, "jun":30,
# "jul": 31, "aug... | true |
62f40aec64258193e15abedd7a346425bbc877b3 | pranakum/Python-Basics | /week 2/course_1_assessment_6/q8.py | 426 | 4.34375 | 4 | '''
Write code to create a list of word lengths for the words in original_str using the accumulation pattern and assign the answer to a variable num_words_list. (You should use the len function).
'''
original_str = "The quick brown rhino jumped over the extremely lazy fox"
#code
str = original_str.split()
print (str)... | true |
7e31942b56635ec1122e4ee36ae7127759ff1d29 | H-B-P/WISHK | /Resources/PYTHON/repeater.py | 593 | 4.28125 | 4 | import sys #Imports sys, the library containing the argv function
the_string=str(sys.argv[1]) #The string to repeat is the first argument given.
target_number_of_repeats=int(sys.argv[2]) #The number of repeats is the second argument given.
number_of_repeats=0 #Set this variable to zero, as there are no repeats at the s... | true |
56a6965014a8d529400257f90556692bb619861d | platinum2015/python2015 | /cas/python_module/v07_nested_functions_2.py | 440 | 4.1875 | 4 | def derivative(my_function):
'''Returns a function that computes the numerical derivative of the given
function my_function'''
def df(x, h=0.0001):
return ((my_function(x+h) - my_function(x-h)) / (2*h))
return df
def f(x):
'''The mathematical function f(x) = x^3'''
return x*... | true |
0b7360bdf8002a8b0c5542ea2cfa08784855be7b | platinum2015/python2015 | /cas/python_module/Day1_SampleSolutions/p02_braking_distance_SOLUTION.py | 1,095 | 4.375 | 4 | # Compute the distance it takes to stop a car
#
# A car driver, driving at velocity v0, suddenly puts on the brake. What
# braking distance d is needed to stop the car? One can derive, from basic
# physics, that
# d=0.5*v_0^2 / mu * g
#
# Develop a program for computing d using the above formula when the ini... | true |
2ff4e164e15623a045036ad189bfab2280086e68 | kpatel1293/CodingDojo | /DojoAssignments/Python/PythonFundamentals/Assignments/12_ScoresAndGrades.py | 907 | 4.375 | 4 | # Assignment: Scores and Grades
# Write a function that generates ten scores between 60 and 100.
# Each time a score is generated, your function should display what the grade
# is for a particular score.
# Here is the grade table:
# Score: 60 - 69; Grade - D
# Score: 70 - 79; Grade - C
# Score: 80 - 8... | true |
fac7cceb04d13dc68e238e969a306522b51c73e9 | kpatel1293/CodingDojo | /DojoAssignments/Python/PythonFundamentals/Assignments/9_FooBar.py | 1,623 | 4.1875 | 4 | # Optional Assignment: Foo and Bar
# Write a program that prints all the prime numbers and all the perfect
# squares for all numbers between 100 and 100000.
# For all numbers between 100 and 100000 test that number for whether
# it is prime or a perfect square. If it is a prime number, print "Foo".
# If it is a pe... | true |
a3b664d4fa3abcccc3cd93690ffe40b053ccf044 | prkhrv/mean-day-problem | /meanday.py | 1,050 | 4.53125 | 5 | """
Mean days
Problem: You are given a list with dates find thee mean day of the given list
Explanation: Given that the range of day values are 1-7 while Monday = 1 and Sunday = 7
Find the "Meanest Day" of the list .
"Meanest Day" is the sum of values of all the days divided by total number of days
For Example:- ... | true |
61895160c36dbfbaafb426cfdbdecc280d6475c9 | lisu1222/towards_datascience | /jumpingOnClouds.py | 1,833 | 4.28125 | 4 | """ Emma is playing a new mobile game that starts with consecutively numbered
clouds. Some of the clouds are thunderheads and others are cumulus. She can jump
on any cumulus cloud having a number that is equal to the number of the current
cloud plus or . She must avoid the thunderheads. Determine the minimum number
of... | true |
01c591c32142f0cb206fbee55375e77ee798121e | momentum-cohort-2019-02/w2d3-word-frequency-rob-taylor543 | /word_frequency.py | 1,769 | 4.125 | 4 | STOP_WORDS = [
'a', 'an', 'and', 'are', 'as', 'at', 'be', 'by', 'for', 'from', 'has', 'he',
'i', 'in', 'is', 'it', 'its', 'of', 'on', 'that', 'the', 'to', 'were',
'will', 'with'
]
import string
def clean(file):
"""Read in a string and remove special characters and stop words (keep spaces). Return the r... | true |
cec4b8438e743ddce8a680a2d4791b3e75dcbb93 | Nas-Islam/qa-python-exercises | /programs/gradecalc.py | 687 | 4.21875 | 4 | def gradeCalc():
print("Welcome to the Grade Calculator!")
mathsmark = int(input("Please enter your maths mark: "))
chemmark = int(input("Please enter your chemistry mark: "))
physicsmark = int(input("Please enter your physics mark: "))
percentage = (mathsmark + chemmark + physicsmark) / 3
if p... | true |
f68a1c9afe8a230e2b9e5ef79982be601a9b97bb | meahow/adventofcode | /2017/06/solution1_test.py | 1,348 | 4.28125 | 4 | import solution1
"""
For example, imagine a scenario with only four memory banks:
The banks start with 0, 2, 7, and 0 blocks. The third bank has the most blocks, so it is chosen for redistribution.
Starting with the next bank (the fourth bank) and then continuing to the first bank, the second bank, and so on, the 7 b... | true |
24cab64adff4d0da92ad5b941b501e355dacfd98 | Iliyakarimi020304/darkT-Tshadow | /term 2/dark shadow51.py | 320 | 4.125 | 4 | number = input("Enter Number: ")
counter = 0
numbers = []
sums = 0
while number != '0':
if number.isdigit():
numbers.append(number)
counter += 1
number = input("Enter Number: ")
for n in numbers:
sums += int(n)
print(f"Your numbers{numbers}")
print(f"Average of your numbers {sums/counter}")
| true |
5c64470d7d305603eb43654528cb7fd6ea78c1cb | MerchenCB2232/backup | /todolist.py | 814 | 4.125 | 4 | import pickle
print ("Welcome to the To Do List :))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))")
todoList = []
while True:
print("Enter a to add an item")
print("Enter r to remove an item")
print("Enter l to load list")
print("Enter p to print the list")
print("Enter q to quit")
choi... | true |
c0d1f2201c3dc6a715ba9994214db7c1d535b453 | cpvp20/bubblesort | /del.py | 378 | 4.21875 | 4 | def sortit(numbers):
for i in range(len(numbers)):
if i[1]>i[2]:
i[1],i[2]=i[2],i[1]
return(numbers)
#ACTIAL CODE
x=list(input("type some integers randomly, separating them with spaces "))
#creates a list with the numbers the user gives
y=[int(i) for i in range(len(x))]#turns list ... | true |
622f93ea01a437ead0616c01901d593092a26927 | rwaidaAlmehanni/python_course | /get_started/Comprehensions/problem28.py | 218 | 4.21875 | 4 | #Write a function enumerate that takes a list and returns a list of tuples containing (index,item) for each item in the list.
def enumerate(array):
print [(array.index(y),y) for y in array]
enumerate(["a", "b", "c"]) | true |
28a6f77cddab8da561601b8f743f57d2e1da03bf | Nzembi123/function.py | /functions.py | 2,647 | 4.3125 | 4 | #Function is a block of code that runs only when called
def adding(num1, num2):
x = num1+num2
print(x)
adding(2,4)
#Multiplication
def multiplication():
num1 =15
num2 =30
sum = num2*num1
print(sum)
multiplication()
##arguments
def courses(*args):
for subject in args:
print(sub... | true |
e214ac661d060b1ce887b15ad66ff44caac1947c | jubic/RP-Misc | /System Scripting/Problem15/6P/t50_xml1.py | 1,763 | 4.21875 | 4 | """
h2. XML from List of Dictionary
Create a function @xmlFromList@ that takes a list of dictionaries. The XML must have the root tag @<storage>@.
Each item in the dictionary should be put inside the @<container>@ tag. The dictionary can contain any keys (just make sure the keys are the same for all of the dictionar... | true |
4a2ce6635442bfaf8555a1958b6dd06b1389d52d | jubic/RP-Misc | /System Scripting/Problem15/t40_db1.py | 1,533 | 4.53125 | 5 | """
h2. Putting Data into SQLite Database
Write a function @putData@ that takes 4 arguments as specified below:
# @dbname@ - a string that specifies the location of the database name
# @fnames@ - the list of first names
# @lnames@ - the list of last names corresponding to the first names list
# @ages@ - the list of... | true |
8ac8ef9b63495ec2678dbad87faa668c9d4d9924 | jubic/RP-Misc | /System Scripting/Problem15/t02_list3.py | 665 | 4.21875 | 4 | """
h2. Zip Two Lists into One
Write a function @zipper@ that takes 2 arguments.
Both arguments are lists of integers. The function must then create a new list to put the first item of the first list, followed by the first item of the second list. Then second item of the first list, followed by the second item in the... | true |
4c4bb3ad3c2b0a45b1b044891d10805fccabb614 | Montanaz0r/Skychallenge-Chapter_II | /I_write_my_programs_in_JSON/I_write_my_programs_in_JSON.py | 629 | 4.25 | 4 | import re
def sum_the_numbers(filename):
"""
A function that sum up all the numbers encountered in the file
:param filename: name of the file (str)
:return: sum of all numbers (int)
"""
with open(f'{filename}.txt', 'r') as file:
data = file.read()
results = re.findall(... | true |
beaaff1569c17464bb006805d7f2f20ae0b7457a | SpikyClip/rosalind-solutions | /bioinformatics_stronghold/FIB_rabbits_and_recurrence_relations.py | 2,483 | 4.40625 | 4 | # url: http://rosalind.info/problems/fib/
# Problem
# A sequence is an ordered collection of objects (usually numbers), which
# are allowed to repeat. Sequences can be finite or infinite. Two examples
# are the finite sequence (π,−2–√,0,π) and the infinite sequence of odd
# numbers (1,3,5,7,9,…). We use the notatio... | true |
e8bcb65bd9bb11fd4a11c030c0885dda1669c43b | SpikyClip/rosalind-solutions | /bioinformatics_stronghold/MRNA_inferring_mRNA_from_protein.py | 2,808 | 4.28125 | 4 | # url: http://rosalind.info/problems/mrna/
# Problem
# For positive integers a and n, a modulo n (written amodn in shorthand)
# is the remainder when a is divided by n. For example, 29mod11=7
# because 29=11×2+7.
# Modular arithmetic is the study of addition, subtraction, multiplication,
# and division with respect ... | true |
1e0382442c4c5c2c87899e2084d88182bf589c11 | VIncentTetteh/Python-programming-basics | /my_math.py | 868 | 4.125 | 4 | import math
def calculate(enter, number1, number2):
print("choose from the list.")
print(" 1. ADD \n 2. SUBTRACT \n 3. MULTIPLY")
if enter == "add" or enter == "ADD":
#number1 = input("enter first number ")
#number2 = int(input(" enter second number "))
answer = number1 + number2
... | true |
95a29801463084c4374fa418b437e2b79719c702 | Aparna9876/cptask | /task9.py | 201 | 4.28125 | 4 | odd = 0
even = 0
for i in (5,6,8,9,2,3,7,1):
if i % 2 == 0:
even = even+1
else:
odd = odd+1
print("Number of even numbers: ",even)
print("Number of odd numbers: ",odd)
| true |
661875f584581198453a3ba706a8dd24f2c71430 | erchiragkhurana/Automation1 | /Python_Practice/Loops/WhileLoop.py | 362 | 4.15625 | 4 | #Initialization, condition then increment
#while loop with increment, while loop is also called indefinte loop
number = input("Write your number")
i=1
while(i<=10):
print(int(number)*i)
i = i + 1
#while loop with decrement
number = input ("your num")
i=10
while(i>=1):
print(int(number)*i)
i=i-2
#another... | true |
61d72a38fbeda9f07c9e3847e50dd85737c94f53 | erchiragkhurana/Automation1 | /Python_Practice/Handling/Condition_Handling.py | 1,511 | 4.46875 | 4 | # take a number from user to check condition handling using if and else
x = input("Hey User type your number")
if(int(x)==100):
print("Number is Greater")
else:
print("Number is smaller")
if(int(x)>100):
print("Number is Greater")
else:
print("Number is smaller")
#check multiple condition handling ... | true |
4aba95f8d59bec6b7be786522f62bcc98b8ca04f | tranhd95/euler | /1.py | 367 | 4.28125 | 4 | """
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
multiplies_of_three = set(range(0, 1000, 3))
multiplies_of_five = set(range(0, 1000, 5))
multiplies = multiplies_of_three.un... | true |
e4a0c67027e213cf03f165c2ccd6b1ccc6c05ba6 | snirsh/intro2cs | /ex2/largest_and_smallest.py | 1,261 | 4.4375 | 4 | ######################################################################
# FILE : largest_and_smallest.py #
# WRITER : Snir Sharristh , snirsh , 305500001 #
# EXERCISE : intro2cs ex2 2015-2016 #
# DESCRIPTION: The code below calcul... | true |
4078dfbb0fa06a2375d323e747edf7bd4aae9d4a | danschae/Python-Tutorial | /introduction/basics.py | 757 | 4.1875 | 4 | """
This section is more just about very basic programming, i'm not putting too much effort into it. This type of information is universal to most programming languages.
"""
print("hello world") # simple console log
print (5 * 7)
print("hello" + " world") # can concatante strings just like in javascript
# greetings... | true |
b3299f6e5d300404892111647477ef82d30dfb1b | Rohit102497/Command_Line_Utility | /web_crawler/links_from_html.py | 1,657 | 4.15625 | 4 | '''
This script prompts a user to pass website url and the html code in string format
and output all the links present in the html in a set.
'''
import re
HREF_REGEX = r"""
href # Matches href command
\s* # Matches 0 or more white spaces
=
\s* # Matches 0 or more w... | true |
491fefbcbebbbe83f59f94b792b123bd2d0a5e0a | Madhu13d/GITDemo | /PythonBasics1/List.py | 1,217 | 4.5 | 4 | values = [1, 2, "Sai", 4, 5]
print(values[0]) # prints 1
print(values[3]) # prints 4
print(values[-1]) # -1 refers to the last element in the list, prints 5
print(values[1:3])#[1:3] is used to get substring.it will fetch 2 values leaving the 3rd index, prints 2, Sai
values.insert(3, "Ramana") # will insert Ramana at 3r... | true |
f88a428b294348655fba37c81c51cce6976e75aa | RumorsHackerSchool/PythonChallengesSolutions | /Guy/hackerrank.com/Python_Division.py | 596 | 4.15625 | 4 | '''
Task
Read two integers and print two lines. The first line should contain integer division, // . The second line should contain float division, / .
You don't need to perform any rounding or formatting operations.
Input Format
The first line contains the first integer, . The second line contains the second integ... | true |
995a1bbf95d98be9fd0ad66d4ffdbef299e9b78d | sudharkj/ml_scripts | /regression/regression_template.py | 1,426 | 4.125 | 4 | # From the course: Machine Learning A-Z™: Hands-On Python & R In Data Science
# https://www.udemy.com/machinelearning/
# dataset: https://www.superdatascience.com/machine-learning/
# Import the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Import the dataset
dataset = pd.read_csv(... | true |
d73be7748c66e2a6d3a50c8d884b4e713dc1b92d | sudharkj/ml_scripts | /regression/simple_linear_regression.py | 1,252 | 4.34375 | 4 | # From the course: Machine Learning A-Z™: Hands-On Python & R In Data Science
# https://www.udemy.com/machinelearning/
# dataset: https://www.superdatascience.com/machine-learning/
# Importing the libraries
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
# Importing the dataset
dataset = pd.rea... | true |
c5cc75fe885f14f205e2b0db8255ef3c580f0684 | Vaild/python-learn | /teacher_cade/day19/7.对象可迭代的.py | 533 | 4.3125 | 4 | #!/usr/bin/python3
# coding=utf-8
class MyList(object):
def __init__(self):
self.container = []
def add(self, item):
self.container.append(item)
# 对象就是可迭代的
def __iter__(self):
return iter(self.container)
mylist = MyList()
mylist.add(1)
mylist.add(2)
mylist.add(3)
for num in ... | true |
1e252b0287dd1146885882d9443fa506a41cdfc6 | chris-miklas/Python | /Lab01/reverse.py | 269 | 4.1875 | 4 | #!/usr/bin/env python3
"""
Print out arguments in reverse order.
"""
import sys
def reverse():
"""
Printing arguments in reverse order.
"""
for i in range(len(sys.argv)-1, 0, -1):
print(sys.argv[i])
if __name__ == "__main__":
reverse()
| true |
86ffb3138d8eb92b4fb9d7834b8411a9e77e1b57 | leoswaldo/acm.tju | /2968_Find-the-Diagonal/find_the_diagonal.py | 1,969 | 4.4375 | 4 | #!/python3/bin/python3
# A square matrix contains equal number of rows and columns. If the order of
# the matrix is known it can be calculated as in the following format:
# Order: 3
# 1 2 3
# 4 5 6
# 7 8 9
# Order: 5
# 1 2 3 4 5
# 6 7 8 9 10
# 11 12 13 ... | true |
24d17e612bfc874dc12d9e3c03d8eb020bf9158a | RanjaniMK/Python-DataScience_Essentials | /creating_a_set_from_a_list.py | 250 | 4.34375 | 4 | # Trying to create a set from a list
# 1. create a list
# 2. create a set
my_list = [1,2,3,4,5]
my_set = set(my_list)
print(my_set)
#Note: The list has square brackets
# The output of a set has curly braces. Like below:
# {1, 2, 3, 4, 5}
| true |
0d55e9a32e80e3bf70ef0534f9f8bda1cec61684 | gjwlsdnr0115/Computer_Programming_Homework | /lab5_2015198005/lab5_p1.py | 431 | 4.28125 | 4 | # initialize largest number variable
largest_num = 0
# variable to stop while loop
more = True
while(more):
num = float(input('Enter a number: '))
if(num > largest_num) :
largest_num = num
if(num == 0):
more = False
if(largest_num > 0): # if there was a positive number input
print('... | true |
069739315c2e7c0c2a2f8e62fb2f4338cb767650 | grahamh21/Python-Crash-Course | /Chapter 4/Try_it_yourself_chapter_4_2.py | 1,560 | 4.34375 | 4 | #Try_it_yourself 4-7
print('Try it yourself 4-7')
threes = list(range(3,31,3))
for three in threes:
print(three)
#Try_it_yourself 4-8
print('Try it yourself 4-8\n')
cubes = []
for cube in range(1,11):
cubes.append(cube**3)
print(cubes)
#Try_it_yourself 4-9
print('Try it yourself 4-9')
#list c... | true |
d758a3f7db1391f62de60fafdb8396d8977f1e70 | sudheer-sanagala/edx-python-course | /WEEK-01/square_of_numbers.py | 522 | 4.125 | 4 | """
Square of a given number
ex: 3^2 = 3*3 = 9; 5^2 = 5*5 = 25
"""
# using while-loop
x = 4
ans = 0
itersLeft = x # no of iterations remaining
while(itersLeft != 0): # while no of iterations not equal to 0
ans = ans + x # add the same number by itself for thje total no of loops
itersLeft = itersLeft - ... | true |
1c6a01ffad2fabee405191e2e4d6e5a6f094d55f | meltedfork/Python-1 | /Python Assignments/Bike_Assignment/bike.py | 890 | 4.21875 | 4 | class bike(object):
def __init__(self,price, max_speed,miles = 0):
self.price = price
self.max_speed = max_speed
self.miles = miles
def displayInfo(self):
print self.price,self.max_speed,self.miles
return self
def ride(self):
print "Riding..."
sel... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.