blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
31f01f01b4e5abec5c6bb6e42ec704047b78d42e | DLaMott/Calculator | /com/Hi/__init__.py | 826 | 4.125 | 4 |
def main():
print('Hello and welcome to my simple calculator.')
print('This is will display different numerical data as a test.')
value = float(input("Please enter a number: "))
value2 = float(input("Please enter a second number: "))
print('These are your two numbers added t... | true |
acf4f9abb3deab9bf3752aae70ac76537f66b92f | GunterBravo/Python_Institute | /2_1_4_10_Lab_Operadores.py | 914 | 4.125 | 4 | ''' Escenario
Observa el código en el editor: lee un valor flotante, lo coloca en una variable llamada x, e imprime el valor de la variable llamada y. Tu tarea es completar el código para evaluar la siguiente expresión:
3x3 - 2x2 + 3x - 1
El resultado debe ser asignado a y.
Recuerda que la notación algebraica clásica... | false |
e48382f4282df95b1f268af7648eec1c885cef18 | viticlick/PythonProjectEuler | /archive1.py | 331 | 4.3125 | 4 | #!/usr/bin/python
"""If we list all the natural numbers below 10 that are multiples of 3 or 5 \
we get 3, 5, 6 and 9. The sumof these multiples is 23.\
\
Find the sum of all the multiples of 3 or 5 below 1000."""
values = [ x for x in range(1,1001) if x % 3 == 0 or x % 5 == 0]
total = sum(values)
print "The result i... | true |
487cc4e6bcbe699a56e2c448cd2d0ad969b75579 | TYakovchenko/GB_Less3 | /less3_HW3.py | 1,196 | 4.25 | 4 | ##3. Реализовать функцию my_func(),
# которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов.
#Первый вариант
def my_func(arg1, arg2, arg3):
if arg1 >= arg3 and arg2 >= arg3:
return arg1 + arg2
elif arg1 > arg2 and arg1 < arg3:
return arg1 + arg3
else:
... | false |
a11e6981301bbdc6a6f55ac7853598ad3b61ede9 | BenjaminFu1/Python-Prep | /square area calculator.py | 205 | 4.1875 | 4 | length=float(input("Give me the lenth of your rectangle"))
width=float(input("Give me the width of your rectangle"))
area=(length) * (width)
print("{0:.1f} is the area of your rectangle".format(area))
| true |
3f620cb320f89f4e0f19bd2d09a30a9b9402b98f | tu-nguyen/linkedinlearning | /Master Python for Data Science/Python Essential Training 1/Chap11/hello.py | 453 | 4.15625 | 4 | #!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
# print('Hello, World.'.swapcase())
# print('Hello, World. {}'.format(42 * 7))
# print("""
# Hello,
# World.
# {}
# """.format(42 * 7))
# s = 'Hello, World. {}'
# print(s.format(42 * 7))
# class MyString(str):
# def __str__(self):
# ... | false |
866c36768b1363d7cd4adef7212458a470e6b0fd | kayshale/ShoppingListApp | /main.py | 1,196 | 4.1875 | 4 | #Kayshale Ortiz
#IS437 Group Assignment 1: Shopping List App
menuOption = None
mylist = []
maxLengthList = 6
menuText = '''
1.) Add Item
2.) Print List
3.) Remove item by number
4.) Save List to file
5.) Load List from file
6.) Exit
'''
while menuOption != '6':
print(menuText)
menuOption = input('Enter Selec... | true |
b0b67fba426642ef56a1cfa5d5e6a65a0286dacb | Rhysoshea/daily_coding_challenges | /other/sort_the_odd.py | 612 | 4.3125 | 4 | '''
You have an array of numbers.
Your task is to sort ascending odd numbers but even numbers must be on their places.
Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it.
Example
sort_array([5, 3, 2, 8, 1, 4]) == [1, 3, 2, 8, 5, 4]
'''
def sort_array(source_arr... | true |
6a02c3fe5111ddf6690e5a060a543164b2db0563 | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily25.py | 1,686 | 4.5 | 4 | """
Implement regular expression matching with the following special characters:
. (period) which matches any single character
* (asterisk) which matches zero or more of the preceding element
That is, implement a function that takes in a string and a valid regular expression and returns whether or not the string match... | true |
be3a184aecc35085a7d69bc447eeaf99d5c2320b | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily44.py | 1,329 | 4.1875 | 4 | # We can determine how "out of order" an array A is by counting the number of inversions it has. Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after a larger element.
# Given an array, count the number of inversions it has. Do this faster than O(N^2) time.
#... | true |
0f01a1e6aa57c4ed9dccf237df27db0465bae2cc | Rhysoshea/daily_coding_challenges | /daily_coding_problems/daily27.py | 848 | 4.15625 | 4 | """
Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed).
For example, given the string "([])[]({})", you should return true.
Given the string "([)]" or "((()", you should return false.
"""
def solution(input):
stack = []
open = ["{", "("... | true |
593e4d4643c9d81098828b22bc68e46c373ffa2c | pbuzzo/backend-katas-functions-loops | /main.py | 1,858 | 4.375 | 4 | #!/usr/bin/env python
"""Implements math functions without using operators except for '+' and '-' """
""" """
__author__ = "Patrick Buzzo"
def add(x, y):
new_num = x + y
return new_num
def multiply(x, y):
new_num = 0
if y >= 0:
for index in range(y):
new_num += x
else:
... | false |
8e3f51ca47d9937f5aae6b56f81bfdba273d3336 | shreyashetty207/python_internship | /Task 4/Prb1.py | 616 | 4.28125 | 4 | #1. Write a program to create a list of n integer values and do the following
#• Add an item in to the list (using function)
#• Delete (using function)
#• Store the largest number from the list to a variable
#• Store the Smallest number from the list to a variable
S = [1, 2, 3,4]
S.append(56)
print('Updated list... | true |
55dca8c77d3eed88301fd93979dbd1b6b4ad657f | brityboy/python-workshop | /day2/exchange.py | 2,914 | 4.125 | 4 | # def test():
# return 'hello'
# this is the game plan
# we are going to make
# a function that will read the data in
# built into this, we are going to make functions that
# 1. creates a list of the differences <- we will use from collections
# Counter in order to get the amounts
# 2. We are going to create a fun... | true |
e71f1186e900a609cfba091f9b972f80222a0a3b | linaresdev/cursoPY3 | /src/practicing/job1/item_3.py | 416 | 4.15625 | 4 | # Realizar un programa en Python que calcule el peso molecular (peso por cantidad de atomos solicitado
# por teclado) de una molecula compuesta de dos elementos
print("CARCULADORA DE PESO MOLECULAR");
peso = ( float(input("Introdusca peso del elemento a calcular:")) * int(input("Indique la cantidad del elemento espe... | false |
178592a57ce09b002482bc4e7638d25730b323ce | Smrcekd/HW070172 | /L03/Excersise 4.py | 385 | 4.34375 | 4 | #convert.py
#A program to convert Celsius temps to Fahrenheit
#reprotudcted by David Smrček
def main():
print("This program can be used to convert temperature from Celsius to Fahrenheit")
for i in range(5):
celsius = eval(input("What is the Celsius temperature? "))
fahrenheit = 9/5*celsius+32
print("The... | true |
ac4e2b8034d0c78d302a02c03fdb45ecb3026b56 | Smrcekd/HW070172 | /L04/Chapter 3/Excersise 15.py | 421 | 4.21875 | 4 | # Program approximates the value of pi
# By summing the terms of series
# by David Smrček
import math#Makes the math library available.
def main():
n = eval(input("Number of terms for the sum: "))
x = 0
m = 1
for i in range (1,2 * n + 1, 2):
x = x + (m *4/i)
m = -m
r... | true |
1c0caaffdef74eb1911756360307908310c811b2 | laviniabivolan/Spanzuratoarea | /MyHangman.py | 2,394 | 4.125 | 4 | import random
def guess_word():
list_of_words = ["starwards", "someone", "powerrangers", "marabu", "mypython", "wordinthelist", "neversurrender"]
random_word = random.choice(list_of_words)
return random_word
def hangman_game():
alphabet = 'abcdefghijklmnoprstuvwxyqz'
word = guess_word()
... | true |
efcb63ba80b697680a8b907923bcbcdc609ae94e | Wmeng98/Leetcode | /Easy/merge_2_sorted_lists.py | 1,295 | 4.21875 | 4 | # Solution 1 - Recursive Approach
# Recursivelly define the merge of two lists as the following...
# Smaller of the two head nodes plus to result of the merge on the rest of the nodes
# Time 0(n+m) and Space O(n+m) -> first recursive call doesn't return untill ends of l1 && l2 have been reached
# Solution 2 - Itera... | true |
ff234acf470b12fe21ee41df3d2a2cf69bd0af91 | tejalbangali/HackerRank-Numpy-Challenge | /Arrays.py | 502 | 4.40625 | 4 | # Task:
# --> You are given a space-separated list of numbers. Your task is to print a reversed NumPy array with the element type float.
# -> Input Format: A single line of input containing space-separated numbers.
# -> Sample Input: 1 2 3 4 -8 -10
# -> Sample Output: [-10. -8. 4. 3. 2. 1.]
import numpy
def... | true |
83243d09a2140da62c7a572d2d887e879801e104 | victordity/PythonExercises | /PythonInterview/binarySearch.py | 1,029 | 4.21875 | 4 | import bisect
def bisect_tutorial():
fruits = ["apple", "banana", "banana", "banana", "orange", "pineapple"]
print(bisect.bisect(fruits, "banana"))
print(bisect.bisect_left(fruits, "banana"))
occurrences = bisect.bisect(fruits, "banana") - bisect.bisect_left(fruits, "banana")
print(occurrences) # ... | true |
38200fdf05a7f80e7bce3773a0f954ec8e3e67f0 | vfperez1/AdivinaNumero | /entrada/menu.py | 744 | 4.125 | 4 | """
Módulo que agrupa todas las funcionalidades
que permiten pedir entrada de números
"""
import sys
def pedirNumeroEntero():
correcto = False
num = 0
while (not correcto):
try:
num = int(input("Eliga una opción del 1 al 4: "))
correcto = True
except ValueError:
... | false |
4d51b16c7673470425579525742dd537470e48b9 | loide/MITx-6.00.1x | /myLog.py | 841 | 4.46875 | 4 | '''
This program computes the logarithm of a number relative to a base.
Inputs:
number: the number to compute the logarithm
base: the base of logarithm
Output:
Logarithm value [ log_base (number) ]
'''
def myLog(number, base):
if ( (type(number) != int) or (number < 0)):
return "Error: Number value must... | true |
579e0da0253ec03a4583ba2288b552b72c0d5ced | anweshachakraborty17/Python_Bootcamp | /P48_Delete a tuple.py | 295 | 4.15625 | 4 | #Delete a tuple
thistuple1 = ("apple", "banana", "mango")
del thistuple1
print(thistuple1) #this will raise an error because the tuple no longer exists
#OUTPUT window will show:
#Traceback (most recent call last): File "./prog.py", line 3, in NameError: name 'thistuple1' is not defined | true |
5cf51d431c50db3886d1daa7c5dc07ea19e133f7 | harsh4251/SimplyPython | /practice/oops/encapsulation.py | 543 | 4.4375 | 4 | class Encapsulation():
def __init__(self, a, b, c):
self.public = a
self._protected = b
self.__private = c
print("Private can only be accessed inside a class {}".format(self.__private))
e = Encapsulation(1,2,3)
print("Public & protacted can be access outside class{},{} ".format(e.public,e._protected))
"""Nam... | true |
259e6161b173cb9975c55427158b13f76750e059 | c42-arun/coding-challenges-python | /src/max_product_of_3_ints/solution_2.1.py | 1,772 | 4.125 | 4 | '''
Greedy approach
- 1 loops
- O(1) space (or O(n)?)
- O(n) time
- considers only +ve ints
'''
def pushDownValues(items, fromIndex):
print(f"Before push: {items[0]}, {items[1]}, {items[2]}: {fromIndex}")
for i in range(len(items) - 1, fromIndex, -1):
print(f"{i - 1} -> {i}")
it... | false |
0b2deb15577ba07a878f00d91eee617d48605bec | beekalam/fundamentals.of.python.data.structures | /ch02/counting.py | 583 | 4.15625 | 4 | """
File: counting.py
prints the number of iterations for problem sizes
that double, using a nested loop
"""
if __name__ == "__main__":
problemSize = 1000
print("%12s%15s" % ("Problem Size", "Iterations"))
for count in range(5):
number = 0
#The start of the algorithm
work = 1
... | true |
8e19018571298372b73695afb9139596e1524464 | MITRE-South-Florida-STEM/ps1-summer-2021-luis-c465 | /ps1c.py | 1,706 | 4.125 | 4 | annual_salary = float(input("Enter the starting salary: "))
total_cost = 1_000_000
semi_annual_raise = .07
portion_down_payment = 0.25
r = 0.04 # Return on investment
total_months = 0
current_savings = 0.0
def down_payment(annual_salary: int, portion_saved: float, total_cost: int,
portion_down_payment: float... | true |
ab872a4d32586fe8cb30a77bf6e212a8512d9c11 | Andrew7891-kip/python_for_intermediates | /copying.py | 918 | 4.21875 | 4 | import copy
# shallow copy
# interferes the original
org = [[0,1,2,3],[5,6,7,8]]
cpy=copy.copy(org)
cpy[0][1]=9
print(cpy)
print(org)
# shallow func copy
class Student:
def __init__(self,name,age):
self.name=name
self.age=age
p1=Student('Andrew',19)
p2 = copy.copy(p1)
p2.age=20
print(p1.age)
... | false |
315ace2527ebf89d6e80aea2a47047f0484f5b40 | Owensb/SnapCracklePop | /snapcrackle.py | 457 | 4.125 | 4 | # Write a program that prints out the numbers 1 to 100 (inclusive).
# If the number is divisible by 3, print Crackle instead of the number.
# If it's divisible by 5, print Pop.
# If it's divisible by both 3 and 5, print CracklePop. You can use any language.
i = []
for i in range (1, 101):
if (i % 3 ==0) & (... | true |
97b2a81aaf57fb021ca6b2c49b7bc925d98ba193 | SeonMoon-Lee/pythonStudy | /class.py | 1,049 | 4.25 | 4 | class Human():
'''인간'''
#person = Human()
#person.name = '철수'
#person.weight = 60.5
def create_human(name,weight):
person = Human()
person.name = name
person.weight = weight
return person
Human.create = create_human
person = Human.create("철수",60.5)
def eat(person):
person.weight+=0.1
pri... | false |
0964f1d92b02db0e9f25664c7049d657c3be4549 | yy02/test | /Python/Python学习笔记/字符串操作.py | 703 | 4.15625 | 4 | str = 'hello world'
# 转换大小写
# print(str.lower())
# print(str.upper())
# 切片操作
# slice[start:end:step] 左闭右开原则,start < value < end
# print(str[2:5])
# print(str[2:])
# print(str[:5])
# print(str[::-1])
# 共有方法
# 相加操作,对字符串列表和元组都可以使用
strA = '人生苦短'
strB = '我用Python'
listA = list(range(10))
listB = list(range(11,20))
# ... | false |
64ba459b0b322274f900e1716496e7643d90bde1 | shermansjliu/Python-Projects | /Ceasar Cipher/Ceaser Cipher.py | 1,888 | 4.21875 | 4 | def ReturnEncryptedString():
code = input("Enter in the code you would like to encrypt")
code = code.upper()
newString = ""
tempArr = list(code)
for oldChar in tempArr:
newString += EncryptKey(oldChar)
print(newString)
def ReturnDecryptedString():
code = input("Enter in the code you ... | true |
48def1c3190fb8e4463f68dd478055621b12e4b6 | yooshxyz/ITP | /Feb19.py | 1,702 | 4.125 | 4 | import random
# answer = answer.strip()[0].lower()
def main():
while True:
user_choice_input = int(input("What Function do you want to Use?\nPlease type 1 for the No vowels function, type 2 for the random vowels function, and 3 for the even or odd calculator.\n"))
if user_choice_input == 1:
... | true |
a09d239c09374761d9c78ae4cfd872eec416a71c | NishadKumar/leetcode-30-day-challenge | /construct-bst-preorder-traversal.py | 1,585 | 4.15625 | 4 | # Return the root node of a binary search tree that matches the given preorder traversal.
# (Recall that a binary search tree is a binary tree where for every node, any descendant of node.left has a value < node.val, and any descendant of node.right has a value > node.val. Also recall that a preorder traversal displa... | true |
b1d83a286acfa0d779945d7ab5f0cfbb608f735e | nandanabhishek/C-programs | /Checking Even or Odd/even_odd.py | 249 | 4.21875 | 4 | a = int(input(" Enter any number to check whether it is even or odd : "))
if (a%2 == 0) :
print(a, "is Even !")
# this syntax inside print statement, automatically adds a space between data separated by comma
else :
print(a, "is Odd !")
| true |
3507349ce69a165ef1b4165843a3ba72e09e4a12 | Rishab-kulkarni/caesar-cipher | /caesar_cipher.py | 1,861 | 4.40625 | 4 | import string
# Enter only alphabets
input_text = input("Enter text to encrypt:").lower()
shift_value = int(input("Enter a shift value:"))
alphabet = string.ascii_lowercase
alphabet = list(alphabet)
def encrypt(input_text,shift_value):
"""
Shifts all the characters present in the input text b... | true |
0e8366c415dd5b7ba4812b30d1a97dd5b4bf7763 | Sipoufo/Python_realisation | /Ex-12/guess_number.py | 1,389 | 4.125 | 4 | from art import logo
import random
print("Welcome to the Number Guessing Game")
# init
live = 0
run = True
# function
def add_live(difficulty):
if difficulty.lower() == 'easy':
return 10
elif difficulty.lower() == 'hard':
return 5
def compare(user, rand):
if user < rand:
print("... | true |
f55819c8e653d6b4d94ad5f74cffd6a8121ddda2 | cmparlettpelleriti/CPSC230ParlettPelleriti | /Lectures/Dictionaries_23.py | 2,317 | 4.375 | 4 | # in with dictionaries
grades = {"John": 97.6,
"Randall": 80.45,
"Kim": 67.5,
"Linda": 50.2,
"Sarah": 99.2}
## check if the student is in there
name = input("Who's grade do you want? ")
print(name in grades)
## if not there, add them
name = input("Who's grade do you want? ").capitalize()
if name in grades:
prin... | true |
781947d55ede62f31a47dc2a4c17cd7eef4007db | EduardoHenSil/testes_python3 | /iteraveis/itertools/accumulate.py | 650 | 4.28125 | 4 | #!/usr/bin/python3
# coding: utf-8
import itertools
import operator
summary = """
itertools.accumulate(it, [func])
Produz somas accumuladas; se func for especificada, entrega o resultado da sua aplicação
ao primeiro par de itens de it, em seguida ao primeiro resultado e o próximo item.
Diferente da função functools.r... | false |
7a683f984c9fba0e0c3d2d53fa805e841d2d29dd | KR4705/algorithms | /routeFinder.py | 1,019 | 4.15625 | 4 | # need to implement a simple path finding game in python.
# import pprint
board = [[0]*7 for _ in range(7)]
def print_grid(grid):
for row in grid:
for e in row:
print e,
print
# print print_grid(board)
def set_goal(a,b):
board[a][b] = "g"
# set_goal(3,3)
# print print_grid(board... | false |
39a97c3366248770fba81735c9c4e231b34077b9 | kuwarkapur/Robot-Automation-using-ROS_2021 | /week 1/assignement.py | 2,292 | 4.3125 | 4 | """Week I Assignment
Simulate the trajectory of a robot approximated using a unicycle model given the
following start states, dt, velocity commands and timesteps
State = (x, y, theta);
Velocity = (v, w)
1. Start=(0, 0, 0); dt=0.1; vel=(1, 0.5); timesteps: 25
2. Start=(0, 0, 1.57); dt=0.2; vel=(0.5, 1); timesteps... | true |
b141ddc29c11db608d165e4c1a9062f27671bee6 | sanjeevs/AlgoByTimPart1 | /assignment3/qsort/qsort.py | 2,243 | 4.1875 | 4 | from math import floor
def qsort(a, lhs, rhs, num_cmps):
""" Sort the array and record the number of comparisons.
>>> a = [2,1]
>>> num_cmps = 0
>>> qsort(a, 0, 1, num_cmps)
1
>>> print(a)
[1, 2]
"""
if((rhs - lhs) >= 1):
num_cmps += (rhs - lhs)
pivot = partition(a, lhs, rhs)
num_cmps =... | false |
22e283d052f9b9931bf09c823dfb93dba87b33ed | Aijaz12550/python | /list/main.py | 953 | 4.375 | 4 |
#########################
##### remove method #####
#########################
list1 = [ 1, 2, True, "aijaz", "test"]
"""
list.remove(arg) it will take one item of list
as a argument to remove from list
"""
list1.remove(1) # it will remove 1 from list1
#list1.remove(99) # it will throw error because 99 is not exi... | true |
43224d710674f33eafd7a5d1b0feb25bfec35141 | FlyingEwok/Linear-BinarySearch | /binarysearch.py | 1,116 | 4.21875 | 4 | def binarySearch (list, l, listLength, value):
# Set up mid point variable
if listLength >= l:
midPoint = l + (listLength - l) // 2
if list[midPoint] == value: # return the midpoint if the value is midpoint
return midPoint
elif list[midPoint] > value: # Do a search to... | true |
0c98cf632b5e8638d1eb2e1f576b0bf667c10fe1 | YunusEmreAlps/Python-Basics | /3. Advanced/Inheritence.py | 2,315 | 4.25 | 4 | # Inheritence (Kalıtım)
# Inheritance belirttiğimiz başka classlardaki method ve attribute'lara erişmemizi sağlar.
# Diyelim ki farklı tipte çalışanlar yaratmak istiyorum IT ve HR olsun.
class Employee:
raise_percent = 0.5
num_emp = 0
def __init__(self, name, last, age, pay):
self.name = name... | false |
15bf570be794b9919f43b5786f61a8a97eb81d31 | YunusEmreAlps/Python-Basics | /2. Basic/Output.py | 1,846 | 4.34375 | 4 | # --------------------
# Example 1 (Output)
# This is comment
"""
This
is
multi-line
comments
"""
# if you want to show something on console
# you need to use a "print" instruction
# syntax:
# print('Message') -> single quotes
# print("Message") -> double quotes
print(' - Hello World!')
print(" - I love Python pr... | true |
f5f54b5db00added0abbf07df9fa2c38bb2e2fbc | compsciprep-acsl-2020/2019-2020-ACSL-Python-Akshay | /class10-05/calculator.py | 844 | 4.21875 | 4 | #get the first number
#get the second number
#make an individual function to add, subtract, multiply and divide
#return from each function
#template for add function
def add(num1, num2):
return (num1+num2)
def sub(num1, num2):
return (num1-num2)
def multiply(num1, num2):
return (num1*num2)
def division... | true |
8d438c71959d3fd16bffc44490bdfea783fcf61d | vassmate/Learn_Python_THW | /mystuff/ex3.py | 1,312 | 4.8125 | 5 | # http://learnpythonthehardway.org/book/ex3.html
# This will print out: "I will count my chickens:".
print "I will count my chikens:"
# This will print out how much Hens we have.
print "Hens", 25.0 + 30.0 / 6.0
# This will print out how much roosters we have.
print "Roosters", 100.0 - 25.0 * 3.0 % 4.0
# This will pr... | true |
1abd8eea6ff68cbb119651fc9e978bef80dfa1a8 | thenickforero/holbertonschool-machine_learning | /math/0x00-linear_algebra/2-size_me_please.py | 577 | 4.4375 | 4 | #!/usr/bin/env python3
"""Module to compute the shape of a matrix"""
def matrix_shape(matrix):
"""Calculates the shape of a matrix.
Arguments:
matrix (list): the matrix that will be processed
Returns:
tuple: a tuple that contains the shape of every dimmension
in the matr... | true |
79969b00b7683284a24114fa72d3b613caf1d3d2 | thenickforero/holbertonschool-machine_learning | /math/0x00-linear_algebra/14-saddle_up.py | 598 | 4.15625 | 4 | #!/usr/bin/env python3
"""Module to compute matrix multiplications.
"""
import numpy as np
def np_matmul(mat1, mat2):
"""Calculate the multiplication of two NumPy Arrays.
Arguments:
mat1 (numpy.ndarray): a NumPy array that normally represents a square
matrix.
... | true |
a403e25b42db8d2b9033c06b5aac45074300d4b3 | dkrusch/python | /lists/planets.py | 1,109 | 4.40625 | 4 | planet_list = ["Mercury", "Mars"]
planet_list.append("Jupiter")
planet_list.append("Saturn")
planet_list.extend(["Uranus", "Neptune"])
planet_list.insert(1, "Earth")
planet_list.insert(1, "Venus")
planet_list.append("Pluto")
slice_rock = slice(0, 4)
rocky_planets = planet_list[slice_rock]
del[planet_list[8]]
# Use appe... | true |
94d4dae91040dd8a74cce61e0977cc3931760ac0 | mali44/PythonPracticing | /Palindrome1.py | 645 | 4.28125 | 4 |
#Ask the user for a string and print out whether this string is a palindrome or not.
#(A palindrome is a string that reads the same forwards and backwards.)
mystr1= input("Give a String")
fromLeft=0
fromRight=1
pointer=0
while True:
if fromLeft > int(len(mystr1)):
break
if fromRight > int(len(mys... | true |
71dad1096b5699d19ad30d431d025aa12b8165f4 | E-Cell-VSSUT/coders | /python/IBAN.py | 2,276 | 4.125 | 4 | # IBAN ( International Bank Account Number ) Validator
'''
An IBAN-compliant account number consists of:
-->a two-letter country code taken from the ISO 3166-1 standard (e.g., FR for France, GB for Great Britain, DE for Germany, and so on)
-->two check digits used to perform the validity checks - fast and simple, but n... | true |
68e650fa51502dcc2a1e15bb7b956cb0c8630c58 | E-Cell-VSSUT/coders | /python/Fibonacci.py | 750 | 4.3125 | 4 | # -- Case-1 -->> Using Function
# This is a program to find fibonacci series using simple function
def fib(n):
if n < 1: # Fibonacci is not defined for negative numbers
return None
if n < 3: # The first two elements of fibonacci are 1
return 1
elem1 = elem2 = 1
sum = 0
for i in ran... | true |
0a95d362e7e9afd2c4c95d3937dfd9c7914ea2d7 | Ispaniolochka/lab_python | /3_3_math_sin.py | 393 | 4.3125 | 4 | '''Написать программу, вычисляющую значение
функции (на вход подается вещественное число):'''
import math
def value(x):
if 0.2<= x <= 0.9:
print('результат:', math.sin(x))
else:
print('результат:',1)
element=input('Введите число:')
result=value(float(element))
| false |
5eec04b7937ecc36999127b68edf991e68db7cf7 | Remor53/lesson2 | /strings.py | 1,256 | 4.375 | 4 | def str_check(str1, str2):
"""Проверяет объекты на пренадлежность типу string.
Если оба объекта строки, то проверяет одинаковые ли они,
если разные, то определяет какая длиннее и проверяет, является
ли вторая строка словом 'learn'
Ключевые аргументы:
str1 -- первый объект
str2 -- второй объ... | false |
faf830c550d3166f125c4b846f95de6b1047d5c7 | fbscott/BYU-I | /CS241 (Survey Obj Ort Prog Data Struct)/checkpoints/check02b.py | 682 | 4.21875 | 4 | user_provide_file = input("Enter file: ")
num_lines = 0
num_words = 0
# method for opening file and assigning its contents to a var
# resource: https://runestone.academy/runestone/books/published/thinkcspy/Files/Iteratingoverlinesinafile.html
# file = open(user_provide_file, "r")
# best practice is to use "with" to ... | true |
5b9d02e8b3b62588d1de662ef4321b20097c8f10 | sgriffith3/python_basics_9-14-2020 | /pet_list_challenge.py | 843 | 4.125 | 4 | #Tuesday Morning Challenge:
#Start with this list of pets:
pets = ['fido', 'spot', 'fluffy']
#Use the input() function three times to gather names of three more pets.
pet1 = input("pet 1 name: ")
pet2 = input("pet 2 name: ")
pet3 = input("pet 3 name: ")
#Add each of these new pet names to the pets list.
pets.appen... | true |
ff0c5c38ca1e0d2b8cba59966bfea5cd7a743fc8 | PavlovAlx/repoGeekBrains | /dz5.py | 516 | 4.3125 | 4 | string1 = int(input("введите выручку"))
string2 = int(input("введите издержки"))
if string1 >= string2:
print ("вы работаете с прибылью:", string1-string2)
print ("рентабельность:", string1/string2)
string3 = int(input("численность сотрудников:"))
print ("прибыль на сотрудника:", (string1-string2)... | false |
d503092c169f07e614859b581774ae27fc8c058c | wreyesus/Python-For-Beginners---2 | /0020. List Comprehensions.py | 2,760 | 4.15625 | 4 | #Comprehensions
nums = [1,2,3,4,5,6,7,8,9,10]
# I want 'n' for each 'n' in nums
my_list = []
for n in nums:
my_list.append(n)
print(my_list)
#Using List Comprihension
my_list_com = [n for n in nums]
print(my_list_com)
############
#I want 'n*n' for each 'n' in nums
my_list1 = []
for n in nums... | false |
900733030503c1011f0df3f2e5ee794499e422b0 | wreyesus/Python-For-Beginners---2 | /0025. File Objects - Reading and Writing to Files.py | 474 | 4.375 | 4 | #File Objects - Reading and Writing to Files
'''
Opening a file in reading / writing / append mode
'''
f = open('test.txt','r')
#f = open('test.txt','w') --write
#f = open('test.txt','r+') --read and write
#f = open('test.txt','a') --append
print(f.name) #will print file name
print(f.mode) #wi... | true |
412ac494347bf94d8fc4b42b4775f4516795005d | bryanjulian/Programming-11 | /BryanJulianCoding/Operators and Stuff.py | 1,028 | 4.1875 | 4 | # MATH!
x = 10
print (x)
print ("x")
print ("x =",x)
x = 5
x = x + 1
print(x)
x = 5
x + 1
print (x)
# x + 1 = x Operators must be on the right side of the equation.
# Variables are CASE SENSITIVE.
x = 6
X = 5
print (x)
print (X)
# Use underscores to name variables!
# Addition (+) Subtraction (-) Multiplycation (... | true |
858a56861965e44d0d1b3161957ea9edd11720ef | wangweihao/Python | /2/2-15.py | 511 | 4.1875 | 4 | #!/usr/bin/env python
#coding:UTF-8
myTuple = []
for i in range(3):
temp = raw_input('input:')
myTuple.append(int(temp))
for i in range(3):
print myTuple[i]
if myTuple[0] > myTuple[1]:
temp = myTuple[0]
myTuple[0] = myTuple[1]
myTuple[1] = temp
if myTuple[0] > myTuple[2]:
temp = myTuple[0]
... | false |
9d175894ced0e8687bb5724763722efdeb70741f | Bmcentee148/PythonTheHardWay | /ex_15_commented.py | 743 | 4.34375 | 4 | #import argv from the sys module so we can use it
from sys import argv
# unpack the args into appropriate variables
script, filename = argv
#open the file and stores returned file object in a var
txt_file = open(filename)
# Tells user what file they are about to view contents of
print "Here's your file %r:" % filena... | true |
dcc622587a5c864792d4ab073da0f5ad239907bf | Bmcentee148/PythonTheHardWay | /ex3.py | 825 | 4.375 | 4 | # begin counting chickens
print "I will now count my count my chickens"
#Hens is 25 + (30 / 6) = 30
print "Hens", 25 + 30.0 / 6
#Roosters is 100 - (25 * 3) % 4
print "Roosters", 100 - 25 * 3 % 4
#begin counting eggs
print "Now I will count my eggs"
#eggs is 3 + 2 + 1 - 5 + (4 % 2) - (1/4) + 6
print 3 + 2 + 1 - 5 + 4... | false |
c4d5cc928ee53ccfdd17c60938a7f9d0ee54e0ba | donnell794/Udemy | /Coding Interview Bootcamp/exercises/py/circular/index.py | 533 | 4.1875 | 4 | # --- Directions
# Given a linked list, return true if the list
# is circular, false if it is not.
# --- Examples
# const l = new List();
# const a = new Node('a');
# const b = new Node('b');
# const c = new Node('c');
# l.head = a;
# a.next = b;
# b.next = c;
# c.next = b;
# circular(l) # true
def c... | true |
669afade07619df314a48551e17ad102f28b249f | donnell794/Udemy | /Coding Interview Bootcamp/exercises/py/fib/index.py | 608 | 4.21875 | 4 | # --- Directions
# Print out the n-th entry in the fibonacci series.
# The fibonacci series is an ordering of numbers where
# each number is the sum of the preceeding two.
# For example, the sequence
# [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]
# forms the first ten entries of the fibonacci series.
# Example:
# fib(4) === 3
... | true |
8fa85e0a0b64bcf6b2175da13c5414b6f4397e90 | cmattox4846/PythonPractice | /Pythonintro.py | 2,522 | 4.125 | 4 | # day_of_week = 'Monday'
# print(day_of_week)
# day_of_week = 'Friday'
# print(f"I can't wait until {day_of_week}!")
# animal_input = input('What is your favorite animal?')
# color_input = input('What is your favorite color?')
# print(f"I've never seen a {color_input} {animal_input}")
#**** time of day
# time_of_d... | true |
f6ddfe6d2be79149d6a0b7c7fd373e8524990574 | Hadiyaqoobi/Python-Programming-A-Concise-Introduction | /week2/problem2_8.py | 1,206 | 4.53125 | 5 | '''
Problem 2_8:
The following list gives the hourly temperature during a 24 hour day. Please
write a function, that will take such a list and compute 3 things: average
temperature, high (maximum temperature), and low (minimum temperature) for the
day. I will test with a different set of temperatur... | true |
c9696e77689ca80b0ec5c1a46f9e5a59857c3b57 | tHeMaskedMan981/coding_practice | /problems/dfs_tree/symmetric_tree/recursive.py | 995 | 4.21875 | 4 |
# A node structure
class Node:
# A utility function to create a new node
def __init__(self, key):
self.data = key
self.left = None
self.right = None
class Solution(object):
def isSymmetric(self, root):
if root is None:
return True
r... | true |
62e3168c128f1d16bef0ec4cc31afa2e05ae9cae | IshmaelDojaquez/Python | /Python101/Lists.py | 413 | 4.25 | 4 | names = ['John', 'Bob', 'Sarah', 'Mat', 'Kim']
print(names)
print(names[0]) # you can determine a specific positive or negative index
print(names[2:4]) # you can return names at a index to a given index. Does not include that secondary index
names[0] = 'Howard'
# Practice
numbers = [3, 6, 23, 8, 4, 10]
max =... | true |
e2ba3d2b834e092bd3675fbcf8dbe5c33a31f729 | ajitg9572/session2 | /hackerrank_prob.py | 206 | 4.28125 | 4 | #!/bin/python3
# declare and initialize a list
fruits = ["apple","mango","guava","grapes","pinapple"]
# pritning type of fruits
print (type(fruits))
# printing value
for fruit in fruits:
print(fruit) | true |
7272a47b347604d33c2e3bcca50099c1976da126 | gdof/Amadou_python_learning | /rock_paper_scissor/main.py | 1,345 | 4.34375 | 4 | import random
# We are going to create a rock paper scissor game
print("Do you want a rock, paper, scissor game?")
# create a variable call user_input and port the user a Yes a No
user_input = input("Yes or No? ")
# if the user select no print out "It is sorry to see you don't want to play"
if user_input == "no":
... | true |
30aaffce13d69354705ccb9e3c9c46e565a3b6d2 | Bals-0010/Leet-Code-and-Edabit | /Edabit/Identity matrix.py | 1,664 | 4.28125 | 4 | """
Identity Matrix
An identity matrix is defined as a square matrix with 1s running from the top left of the square to the bottom right. The rest are 0s. The identity matrix has applications ranging from machine learning to the general theory of relativity.
Create a function that takes an integer n and returns th... | true |
d07e252bff50c58d9cf0d612edbdfd78f9a7b7a7 | radhikar408/Assignments_Python | /assignment17/ques1.py | 349 | 4.3125 | 4 | #Q1. Write a python program using tkinter interface to write Hello World and a exit button that closes the interface.
import tkinter
from tkinter import *
import sys
root=Tk()
def show():
print("hello world")
b=Button(root,text="Hello",width=25,command=show)
b2=Button(root,text="exit",width=25, command=exit)
b.pac... | true |
dd579fcf0c2dde41709cc6a552777d799a5240f2 | MattSokol79/Python_Introduction | /python_variables.py | 1,289 | 4.5625 | 5 | # How to create a variable
# If you want to comment out more than one line, highlight it all and CTRL + /
name = "Matt" # String
# Creating a variable called name to store user name
age = 22 # Int
# Creating a variable called age to store age of user
hourly_wage = 10 # Int
# Creating a variable called hourly_wage to... | true |
d7ee9dfcd9573db8b914dc96bff65c61753aceec | fadhilmulyono/CP1401 | /CP1401Lab6/CP1401_Fadhil_Lab6_2.py | 373 | 4.25 | 4 | '''
The formula to convert temperature in Fahrenheit to centigrade is as follows:
c = (f-32)*5/9;
Write a program that has input in Fahrenheit and displays the temperature in Centigrade.
'''
def main():
f = float (input("Enter the temperature in Fahrenheit: "))
c = (f - 32) * 5 / 9
print("The temp... | true |
db9eddc3ae20c784684b86d39aa675cd8764739f | fadhilmulyono/CP1401 | /Prac05/CP1401_Fadhil_Prac5_3.py | 292 | 4.40625 | 4 | '''
Get height
Get weight
Calculate BMI (BMI = weight/(height^2 ))
Show BMI
'''
def main():
height = float(input("Enter your height (m): "))
weight = float(input("Enter your weight (kg): "))
BMI = weight / (height ** 2)
print("Your BMI is " + str(BMI))
main()
| false |
d3e53df801c4e65d76e275b9414312bdb2f618e5 | fadhilmulyono/CP1401 | /Prac08/CP1401_Fadhil_Prac8_3.py | 607 | 4.3125 | 4 | '''
Write a program that will display all numbers from 1 to 50 on separate lines.
For numbers that are divisible by 3 print "Fizz" instead of the number.
For numbers divisible by 5 print the word "Buzz".
For numbers that are divisible by both 3 and 5 print "FizzBuzz".
'''
def main():
number = 0
... | true |
99340807f1f60f51cd4ddd83af753df01b947a89 | oldpride/tpsup | /python3/examples/test_copilot_vscode.py | 232 | 4.28125 | 4 | #!/usr/bin/env python3
import datetime
# get days between two dates
def get_days_between_dates(date1, date2):
return (date2 - date1).days + 1
print(get_days_between_dates(datetime.date(2018, 1, 1), datetime.date(2018, 1, 3))) | false |
1550ef200015ae11c213f5b0762e33a1ae24315c | oldpride/tpsup | /python3/examples/test_nested_dict.py | 210 | 4.40625 | 4 | #!/usr/bin/env python3
import pprint
dict1 = {}
dict2 = {'a': 1, 'b': 2}
dict1['c'] = dict2
print('before, dict1 = ')
pprint.pprint(dict1)
dict2['a'] = 3
print('after, dict1 = ')
pprint.pprint(dict1)
| false |
382700c11c43f4aa36ccdac6076a6b3685243c66 | jasigrace/guess-the-number-game | /main.py | 812 | 4.1875 | 4 | import random
from art import logo
print(logo)
print("Welcome to the Number Guessing Game!")
print("I'm thinking of a number between 1 and 100.")
number = random.randint(1, 100)
def guess_the_number(number_of_attempts):
while number_of_attempts > 0:
print(f"You have {number_of_attempts} remaining to guess the n... | true |
3654c6e6941304f8e95e428b490f68e7b6bb4227 | randy-wittorp/ex | /ex39.py~ | 2,518 | 4.125 | 4 | # create a mapping of state to abbreviation
states = {
'Oregon': 'OR',
'Florida': 'FL',
'California': 'CA',
'New York': 'NY',
'Michigan': 'MI'
}
# create a basic set of states and some cities in them
cities = {
'CA': 'San Francisco',
'MI': 'Detroit',
'FL': 'Jacksongille'
}
# add some m... | false |
48c2d231d58a0b04c6c91e529ee98bf985988857 | ernur1/thinking-recursively | /Chapter-3/3.2-factorial.py | 392 | 4.28125 | 4 | #===============================================================================
# find the factorial of the given integer
#===============================================================================
def factorial(num):
if (num == 0):
return 1
else:
return num * factorial(num-1)
if __name_... | true |
752eb476bdcfb40289559b662245786b635c1766 | ellen-yan/self-learning | /LearnPythonHardWay/ex33.py | 362 | 4.15625 | 4 | def print_num(highest, increment):
i = 0
numbers = []
while i < highest:
print "At the top i is %d" % i
numbers.append(i)
i = i + increment
print "Numbers now: ", numbers
print "At the bottom i is %d" % i
return numbers
print "The numbers: "
numbers = print_nu... | true |
1ce6ad0a83e82ade475c75c40d9cf5c8fb4cac43 | ellen-yan/self-learning | /LearnPythonHardWay/ex5.py | 1,363 | 4.34375 | 4 | my_name = 'Ellen X. Yan'
my_age = 23 # not a lie
my_height = 65 # inches
my_weight = 135 # lbs
my_eyes = 'Brown'
my_teeth = 'White'
my_hair = 'Black'
print "Let's talk about %s." % my_name
print "She's %d inches tall." % my_height
print "She's %d pounds heavy." % my_weight
print "Actually that's not too heavy."
print ... | true |
a6f237792aef743e05e0e1d0f81e510b0926bdec | nsimsofmordor/PythonProjects | /Projects/PythonPractice.org/p2_odd_or_even.py | 481 | 4.40625 | 4 | # Ask the user for a number.
# Depending on whether the number is even or odd, print out an appropriate message to the user.
# If the number is a multiple of 4, print out a different message.
# Ask for a positive number
number = int(input("Enter a positive number: "))
while number < 0:
number = int(input("Enter ... | true |
ee6fcba43821b771900c0ced8ca27003e6085fd0 | nsimsofmordor/PythonProjects | /Projects/PythonPractice.org/p6_sting_lists.py | 287 | 4.53125 | 5 | # Ask the user for a string and print out whether this string is a palindrome or not.
my_str = str(input("Enter a string to check if it is a palindrome or not: ").lower())
rev_str = my_str[::-1].lower()
if my_str == rev_str:
print("Palindrome!")
else:
print("Not Palindrome!") | true |
068905cbe2bea0582747af13f294ce98d8edf24f | nsimsofmordor/PythonProjects | /Projects/Python_Tutorials_Corey_Schafer/PPBT5 Dicts.py | 1,064 | 4.375 | 4 | # {Key:value} == {Identifier:Data}
student = {'name': 'john', 'age': '27', 'courses': ['Math', 'Science']}
print(f"student = {student}")
print(f"student[name] = {student['name']}")
print(f"student['courses'] = {student['courses']}\n")
# print(student['Phone']) # throws a KeyError, sine that key doesn't exist
print(... | true |
14325d0779ae0aa4b96b89daddcaef7448493106 | msossoman/coderin90 | /calculator.py | 1,165 | 4.125 | 4 | def add (a, b):
c = a + b
print "The answer is: {0} + {1} = {2}".format(a, b, c)
def subtract (a, b):
c = a - b
print "The answer is {0} - {1} = {2}".format(a, b, c)
def multiply (a, b):
c = a * b
print "The answer is {0} * {1} = {2}".format(a, b, c)
def divide (a, b):
c = a / b
print "The answer is {0} / {1... | true |
1b26680c89752d77a1f78e231a9165c4a25a004c | Ashok-Mishra/python-samples | /python exercises/dek_program054.py | 864 | 4.4375 | 4 | # !/user/bin/python
# -*- coding: utf-8 -*-
#- Author : (DEK) Devendra Kavthekar
# Define a class named Shape and its subclass Square. The Square class has
# an init function which takes a length as argument. Both classes have a
# area function which can print the area of the shape where Shape's area
# is 0 by default... | true |
40746a8b06658c8d7935e4238f69e17e1d7d9315 | Ashok-Mishra/python-samples | /python exercises/dek_program068.py | 970 | 4.40625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
#- Author : (DEK) Devendra Kavthekar
# program068:
# Please write a program using generator to print the even numbers between
# 0 and n in comma separated form while n is input by console.
# Example:
# If the following n is given as input to the program:
# 10
# The... | true |
e260d508fca7871b4955a4d44eded3503d532c18 | Ashok-Mishra/python-samples | /python exercises/dek_program062.py | 482 | 4.40625 | 4 | # !/user/bin/python
# -*- coding: utf-8 -*-
#- Author : (DEK) Devendra Kavthekar
# Write a program to read an ASCII string and to convert it to a unicode
# string encoded by utf - 8.
# Hints:
# Use unicode() function to convert.
def do(sentence):
# print ord('as')
unicodeString = unicode(sentence, "... | true |
047481cff2b6856af271cecf82fbeb71e1e68ad3 | Ashok-Mishra/python-samples | /python exercises/dek_program071.py | 571 | 4.40625 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
#- Author : (DEK) Devendra Kavthekar
# program071:
# Please write a program which accepts basic mathematic expression from
# console and print the evaluation result.
# Example:
# If the following string is given as input to the program:
# 35+3
# Then, the output of... | true |
d502383264e8d290050e3b1384916f7888c07677 | Ashok-Mishra/python-samples | /python exercises/dek_program045.py | 694 | 4.375 | 4 | # !/user/bin/python
# -*- coding: utf-8 -*-
#- Author : (DEK) Devendra Kavthekar
# Write a program which can filter even numbers in a list by using filter
# function. The list is:
# [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].
# Hints:
# Use filter() to filter some elements in a list.
# Use lambda to define anonymous functio... | true |
714da2929f26a6b2788bad27279aec26de30f66b | Ashok-Mishra/python-samples | /python exercises/dek_program053.py | 747 | 4.28125 | 4 | # !/user/bin/python
# -*- coding: utf-8 -*-
#- Author : (DEK) Devendra Kavthekar
# Define a class named Rectangle which can be constructed by a length and
# width. The Rectangle class has a method which can compute the area.
# Hints:
# Use def methodName(self) to define a method.
class Ractangle(object):
def _... | true |
ef2f0b6305acf196994ca53109035688722d342e | Ashok-Mishra/python-samples | /python exercises/dek_program001.py | 913 | 4.125 | 4 | #!/user/bin/python
# -*- coding: utf-8 -*-
# Author : (DEK) Devendra Kavthekar
# program001 : divisibleBy7not5
# Write a program which will find all such numbers which are divisible by 7
# but are not a multiple of 5, between 2000 and 3200 (both included).
# The numbers obtained should be printed in a comma-separate... | true |
ae0fed29cb1b49c8deb8c0807df7f222c6aae61a | Ashok-Mishra/python-samples | /python exercises/dek_program008.py | 722 | 4.28125 | 4 | #!/user/bin/python
# -*- coding: utf-8 -*-
# Author : (DEK) Devendra Kavthekar
# program008 :
# Write a program that accepts a comma separated
# sequence of words as input and prints the words
# in a comma-separated sequence after sorting them alphabetically.
# Suppose the following input is supplied to the program:... | true |
bb8be1f8046be290b5a453dcae9774bbac3df864 | analBrotherhood/UCrypt-CLI | /ucrypt.py | 1,649 | 4.21875 | 4 | alphabet = '=>?@[\\]678hiVWlmABCDEpqrsjkJKL01234RюБжэяЩРтшЦМйu&UмоПtлС5хКцvЧёgчwSещFTвНZ#ОькТЖЯЁфбГъуЗиргШЪ$ЮХыЫIXHЕ!ВДG"Фа%АYсЙЬИздЛoxyz<MNOPQnУЭпн9abcdef^_`{|}~ \'()*+,-./:;'
def encrypt():
enc = ''
msg = input('Type message for encrypting: ')
key = input('Enter key for encrypting: ')
for c... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.