blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
72a5f79be816896fcdfbab8dd0a54f1588d25551 | jeremyyew/tech-prep-jeremy.io | /code/topics/1-searching-and-sorting/M148-sorted-list.py | 1,589 | 4.125 | 4 | Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def sortList(self, head):
pass
# Iterative mergesort function to
# sort arr[0...n-1]
def mergeSort(self, head):
current_size = 1
left = he... | true |
5ccb88df6a21f7a105c7c08d2551412c4cc307bb | sachin1005singh/complete-python | /python_program/findvowel.py | 218 | 4.28125 | 4 | #vowels program use of for loop
vowel = "aeiouAEIOU"
while True:
v = input("enter a vowel :")
if v in vowel:
break
print("this in not a vowel ! try again !!")
print("thank you")
| true |
74a079f8a0c40df56f5412dd4723cb2368b3759a | kartsridhar/Problem-Solving | /halindrome.py | 1,382 | 4.25 | 4 | """
Given a string S. divide S into 2 equal parts S1 and S2. S is a halindrome if
AT LEAST one of the following conditions satisfy:
1. S is a palindrome and of length S >= 2
2. S1 is a halindrome
3. S2 is a halindrome
In case of an odd length string, S1 = [0, m-1] and S2 = [m+1, len(s)-1]
Example 1:
input: harshk
ou... | true |
408d751896467c077d7dbc1ac9ffe6239fed474d | kartsridhar/Problem-Solving | /HackerRank/Problem-Solving/Basic-Certification/unexpectedDemand.py | 1,630 | 4.40625 | 4 | #!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'filledOrders' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. INTEGER_ARRAY order
# 2. INTEGER k
#
"""
A widget manufacturer is facing unexpectedly high d... | true |
914c7c8db0d3d316d22d899ba6756368ae4eb392 | pythonmite/Daily-Coding-Problem | /problem_6_medium.py | 514 | 4.1875 | 4 | """
Company Name : DropBox
Problem Statement : Find the second largest element in the list. For example: list :[2,3,5,6,6]
secondlargestelement >>> [5]
"""
def findSecondLargestNum(arr:list):
max = arr[0]
for num in arr:
if num > max:
max = num
secondlargest = 0
f... | true |
de1515c2150e80505cca6fbec738b38bc896487f | KarenRdzHdz/Juego-Parabolico | /parabolico.py | 2,756 | 4.34375 | 4 | """Cannon, hitting targets with projectiles.
Exercises
1. Keep score by counting target hits.
2. Vary the effect of gravity.
3. Apply gravity to the targets.
4. Change the speed of the ball.
Integrantes:
Karen Lizette Rodríguez Hernández - A01197734
Jorge Eduardo Arias Arias - A01570549
Hernán Salinas Ibarra - A0157... | true |
627a95962abed7b46f673bf813375562b3fa1cd2 | imruljubair/imruljubair.github.io | /teaching/material/List/7.py | 413 | 4.375 | 4 | # append()
# Example 7.1
def main():
name_list = []
again = 'y'
while again == 'y':
name = input("Enter a name : ")
name_list.append(name)
print('Do you want to add another name ?')
again = input('y = yes, anything else = no: ')
print()
print(... | true |
0c110fece3e121665c41b7f1c039c190ed1b7866 | imruljubair/imruljubair.github.io | /teaching/material/List/5.py | 268 | 4.28125 | 4 | # Concating and slicing list
# Example 5.1
list1 = [1,2,3]
list2 = [4,5,6]
list3 = list1 + list2
print(list3)
# Example 5.2
days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Satureday']
mid_days = days[2:5]
print(mid_days)
| true |
aea3ddf894c253cfe9bcdae7a3878f67bf76a5b7 | softwaresaved/docandcover | /fileListGetter.py | 1,118 | 4.375 | 4 | import os
def fileListGetter(directory):
"""
Function to get list of files and language types
Inputs: directory: Stirng containing path to search for files in.
Outputs: List of Lists. Lists are of format, [filename, language type]
"""
fileLists = []
for root, dirs, files in os.walk(dire... | true |
384785ebd3f0e57cc68ac0cd00389f4bcfd8b245 | AffanIndo/python-script | /caesar.py | 702 | 4.21875 | 4 | #!usr/bin/env python
"""
caesar.py
Encrypt or decrypt text based from caesar cipher
Source: http://stackoverflow.com/questions/8886947/caesar-cipher-function-in-python
"""
def caesar(plainText, shift):
cipherText = ""
for ch in plainText:
if ch.isalpha():
stayInAlphabet = ord(ch) + shift
... | true |
20ffbd80d572fd4b75db8860c04c034cb6d87ab0 | midephysco/midepython | /exercises2.py | 250 | 4.125 | 4 | #this is a program to enter 2 numbers and output the remainder
n0 = input("enter a number ")
n1 = input("enter another number")
div = int(n0) / int(n1)
remainder = int(n0) % int(n1)
print("the answer is {0} remainder {1}".format(div, remainder)) | true |
19665f62b7fa38f9cbc82e17e02dacd6de092714 | midephysco/midepython | /whileloop2.py | 452 | 4.21875 | 4 | #continous loop
print("Adding until rogue value")
print()
print("This program adds up values until a rogue values is entered ")
print()
print("it then displays the sum of the values entered ")
print()
Value = None
Total = 0
while Value != 0:
print("The total is: {0}.".format(Total))
print()
Value = int(i... | true |
cdfad3f2a3b8d22c82c203195a5c03ec456111e6 | VineethChandha/Cylinder | /loops.py | 987 | 4.125 | 4 | # PY.01.10 introduction to the loops
for a in range(1,11): # a will be valuated from 1 to 10
print("Hi")
print(a)
even_numbers = [x for x in range(1,100) if x%2 == 0]
print(even_numbers)
odd_numbers = [x for x in range(1,100) if x%2 != 0]
print(odd_numbers)
words = ["ram","krishna","sai"]
answ... | true |
aaf7a5a0a5195ff1376ef2f0d6e6f84ffc273341 | XxdpavelxX/Python3 | /L3 Iteration in Python/decoder.py | 1,682 | 4.625 | 5 | """Create a Python3_Homework03 project and assign it to your Python3_Homework working set. In the
Python3_Homework03/src folder, create a file named decoder.py, which contains an iterator named alphabator.
When passed a list, simply return objects as-is unless they are integers between 1 and 26, in which case it
sho... | true |
0a78c83f9ef57d9b72a23fe657ed93c9761f3e3e | XxdpavelxX/Python3 | /L4 Basic Regular Expressions/find_regex.py | 1,719 | 4.3125 | 4 | """Here are your instructions:
Create a Python3_Homework04 project and assign it to your Python3_Homework working set. In the Python3_Homework04/src
folder, create a program named find_regex.py that takes the following text and finds the start and end positions of the
phrase, "Regular Expressions".
Text to use in ... | true |
ccc8620d0ec8f4dd1fdf13800ce16db8efa218ff | BiancaHofman/python_practice | /ex37_return_and_lambda.py | 744 | 4.3125 | 4 | #1. Normal function that returns the result 36
#And this result is printed
def name():
a = 6
return a * 6
print(name())
#2. Normal function that only prints the result 36
def name():
a = 6
print(a * 6)
name()
#3. Anonymous function that returns the result 36
#And this result is printed
x =... | true |
2cf1813ba0c933c00afef4c26bec91ec7b1494ff | johnsbuck/MapGeneration | /Utilities/norm.py | 1,596 | 4.34375 | 4 | """N-Dimensional Norm
Defines the norm of 2 points in N dimensional space with different norms.
"""
import numpy as np
def norm(a, pow=2):
""" Lp Norm
Arguments:
a (numpy.ndarray): A numpy array of shape (2,). Defines a point in 2-D space.
pow (float): The norm used for distance (Default: 2... | true |
81a1ab2f702bd56d5379540bee0e14044661a958 | Manmohit10/data-analysis-with-python-summer-2021 | /part01-e07_areas_of_shapes/src/areas_of_shapes.py | 864 | 4.21875 | 4 | #!/usr/bin/env python3
import math
def main():
while True:
shape=input("Choose a shape (triangle, rectangle, circle):")
shape=str(shape)
if shape=="":
break
elif shape=='triangle':
base=float(input('Give base of the triangle:'))
height=float(inp... | true |
87b47edb3ac4c944e7498021311d29a683de4873 | mashanivas/python | /scripts/fl.py | 208 | 4.28125 | 4 | #!/usr/bin/python
#Function for powering
def raise_to_power(base_num, pow_num):
result = 1
for index in range(pow_num):
result = result * base_num
return result
print(raise_to_power(2, 3))
| true |
8570e157445bcbb0d2ff72b5d3c62921d5e084fd | prahaladbelavadi/codecademy | /python/5.making-a-request.py | 1,129 | 4.40625 | 4 | # Making a Request
# You saw a request in the first exercise. Now it's time for you to make your own! (Don't worry, we'll help.)
#
# On line 1, we've imported urlopen from the urllib2 module, which is the Python way of bringing in additional functionality we'll need to make our HTTP request. A module is just a collecti... | true |
ac3a6fcb8237f80f54bd88856cc669d578ea08b5 | kieranmcgregor/Python | /PythonForEverybody/Ch2/Ex2_prime_calc.py | 2,439 | 4.125 | 4 | import sys
def prime_point_calc(numerator, denominator):
# Returns a number if it is a prime number
prime = True
while denominator < numerator:
if (numerator % denominator) == 0:
prime = False
break
else:
denominator += 1
if prime:
return num... | true |
58bfbf28aa758d222f0375e61b4ed2dc95c2c8da | kieranmcgregor/Python | /PythonForEverybody/Ch9/Ex2_Day_Sort.py | 1,767 | 4.15625 | 4 | def quit():
quit = ""
no_answer = True
while no_answer:
answer = input("Would you like to quit? (y/n) ")
try:
quit = answer[0].lower()
no_answer = False
except:
print ("Invalid entry please enter 'y' for yes and 'n' for no.")
continue... | true |
86f91d794953d183366e9290564313d1dcaa594e | gmanacce/STUDENT-REGISTERATION | /looping.py | 348 | 4.34375 | 4 | ###### 11 / 05 / 2019
###### Author Geofrey Manacce
###### LOOPING PROGRAM
####CREATE A LIST
months = ['january','february', 'match', 'april', 'may','june','july','august','september','october','november','december']
print(months)
#####using For loop
for month in months:
print(month.title() + "\n")
print("go for n... | true |
d830adc3169ec263a5043079c99d8a8a65cda037 | orrettb/python_fundamental_course | /02_basic_datatypes/2_strings/02_11_slicing.py | 562 | 4.40625 | 4 | '''
Using string slicing, take in the user's name and print out their name translated to pig latin.
For the purpose of this program, we will say that any word or name can be
translated to pig latin by moving the first letter to the end, followed by "ay".
For example: ryan -> yanray, caden -> adencay
'''
#take the us... | true |
482a4ab3e78e3f5e755ea3ff9b66fc48d3e5860f | BrandonMayU/Think-Like-A-Computer-Scientist-Homework | /7.10 Problems/5.6-17.py | 367 | 4.1875 | 4 | # Use a for statement to print 10 random numbers.
# Repeat the above exercise but this time print 10 random numbers between 25 and 35, inclusive.
import random
count = 1 # This keeps track of how many times the for-loop has looped
print("2")
for i in range(10):
number = random.randint(25,35)
print("Loop: ",c... | true |
b5c3a44e099edcc1974e5854b17e4b2475dc6a76 | Appu13/RandomCodes | /DivideandConquer.py | 678 | 4.1875 | 4 |
'''
Given a mixed array of number and string representations of integers,
add up the string integers and subtract this from the total of the non-string integers.
Return as a number.
'''
def div_con(x):
# Variable to hold the string total
strtot = 0
# Variable to hold the digit total
digitot = 0... | true |
7a049ad9b04e1243ad1f440447d89fe112979633 | Mvk122/misc | /CoinCounterInterviewQuestion.py | 948 | 4.15625 | 4 | """
Question: Find the amount of coins required to give the amount of cents given
The second function gets the types of coins whereas the first one only gives the total amount.
"""
def coin_number(cents):
coinlist = [25, 10, 5, 1]
coinlist.sort(reverse=True)
"""
list must be in descending order
... | true |
8ce075118b7aca2dd2dc8f54eb59146e8c4edaf4 | Svanfridurjulia/FORRITUN-SJS-HR | /Hlutapróf 2/prófdæmi.py | 1,553 | 4.3125 | 4 | def sum_number(n):
'''A function which finds the sum of 1..n and returns it'''
sum_of_range = 0
for num in range (1,n+1):
sum_of_range += num
return sum_of_range
def product(n):
'''A function which finds the product of 1..n and returns it'''
multi = 1
for num in range(1,n+1):
... | true |
7c041a0333ad9a58383c495981485c535f6aa8bd | Svanfridurjulia/FORRITUN-SJS-HR | /æfingapróf/dæmi2.py | 878 | 4.21875 | 4 |
def open_file(filename):
opened_file = open(filename,"r")
return opened_file
def make_list(opened_file):
file_list = []
for lines in opened_file:
split_lines = lines.split()
file_list.append(split_lines)
return file_list
def count_words(file_list):
word_count = 0
punctua... | true |
9be417a8ba86044f1b8717d993f44660adfbf9cd | Svanfridurjulia/FORRITUN-SJS-HR | /æfing.py | 1,056 | 4.3125 | 4 |
def find_and_replace(string,find_string,replace_string):
if find_string in string:
final_string = string.replace(find_string,replace_string)
return final_string
else:
print("Invalid input!")
def remove(string,remove_string):
if remove_string in string:
final2_string = stri... | true |
f0d663cbc1f64b3d08e61927d47f451272dfd746 | Hiradoras/Python-Exercies | /30-May/Valid Parentheses.py | 1,180 | 4.375 | 4 | '''
Write a function that takes a string of parentheses, and determines
if the order of the parentheses is valid. The function should return
true if the string is valid, and false if it's invalid.
Examples
"()" => true
")(()))" => false
"(" => false
"(())((()())())" => true
Con... | true |
cf9270abd93e8b59cdb717deeea731308bf5528d | Hiradoras/Python-Exercies | /29-May-2021/Reverse every other word in the string.py | 895 | 4.25 | 4 | '''
Reverse every other word in a given string, then return the string.
Throw away any leading or trailing whitespace, while ensuring there
is exactly one space between each word. Punctuation marks should be
treated as if they are a part of the word in this kata.
'''
def reverse_alternate(string):
words = string.s... | true |
dc4cfcc11c9b26f1e27874d1b9ac84291664b33c | susanbruce707/hexatrigesimal-to-decimal-calculator | /dec_to_base36_2.py | 696 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Dec 21 23:38:34 2018
Decimal to hexatrigesimal calculator.
convert decimal number to base 36 encoding; use of letters with digits.
@author: susan
"""
def dec_to_base36(dec):
"""
converts decimal dec to base36 number.
returns
-------
sign+resu... | true |
58a9223e31c487b45859dd346238ee84bb2f61c8 | ao-kamal/100-days-of-code | /binarytodecimalconverter.py | 1,485 | 4.34375 | 4 | """Binary to Decimal and Back Converter - Develop a converter to convert a decimal number
to binary or a binary number to its decimal equivalent.
"""
import sys
print(
'This program converts a number from Binary to Decimal or from Decimal to Binary.')
def binary_to_decimal(n):
print(int(str(n), 2), '\n')
d... | true |
c296dab78893f00978039d1a8edee17c8d6d6b3d | lillyfae/cse210-tc05 | /puzzle.py | 1,812 | 4.125 | 4 | import random
class Puzzle:
'''The purpose of this class is to randomly select a word from the word list.
Sterotyope:
Game display
Attributes:
word_list (list): a list of words for the puzzle to choose from
chosen_word (string): a random word from the word list
create_... | true |
e105386bcb9851004f3243f42f385ebc39bac8b7 | KAOSAIN-AKBAR/Python-Walkthrough | /casting_Python.py | 404 | 4.25 | 4 | x = 7
# print the value in float
print(float(x))
# print the value in string format
print(str(x))
# print the value in boolean format
print(bool(x)) # *** in BOOLEAN data type, anything apart from 0 is TRUE. Only 0 is considered as FALSE *** #
print(bool(-2))
print(bool(0))
# type casting string to integer
print(i... | true |
f64eb90364c4acd68aac163e8f76c04c86479393 | KAOSAIN-AKBAR/Python-Walkthrough | /calendar_Python.py | 831 | 4.40625 | 4 | import calendar
import time
# printing header of the week, starting from Monday
print(calendar.weekheader(9) + "\n")
# printing calendar for the a particular month of a year along with spacing between each day
print(calendar.month(2020, 4) + "\n")
# printing a particular month in 2-D array mode
print(calendar.monthc... | true |
3ed6e13c885c7e666fd318e32e3b20278581df18 | kaiyaprovost/algobio_scripts_python | /windChill.py | 1,076 | 4.1875 | 4 | import random
import math
def welcome():
print("This program computes wind chill for temps 20 to -25 degF")
print("in intervals of 5, and for winds 5 to 50mph in intervals of 5")
def computeWindChill(temp,wind):
## input the formula, replacing T with temp and W with wind
wchill = 35.74 + 0.62... | true |
9de3fd928aecb53938eb1ced384dfb9deeb3a5b9 | lzaugg/giphy-streamer | /scroll.py | 1,426 | 4.15625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Console Text Scroller
~~~~~~~~~~~~~~~~~~~~~
Scroll a text on the console.
Don't forget to play with the modifier arguments!
:Copyright: 2007-2008 Jochen Kupperschmidt
:Date: 31-Aug-2008
:License: MIT_
.. _MIT: http://www.opensource.org/licenses/mit-license.php
"""
... | true |
f8f775245f38f0553c139bf3253c449e7bf851d8 | judeinno/CodeInterview | /test/test_Piglatin.py | 941 | 4.15625 | 4 | import unittest
from app.Piglatin import PigLatinConverter
""" These tests are for the piglatin converter"""
class TestConverter(unittest.TestCase):
"""This test makes sure that once the first letters are not vowels they are moved to the end"""
def test_for_none_vowel(self):
self.pig = PigLatinConve... | true |
5b2887021b660dfb5bca37a6b395b121759fed0a | Kontetsu/pythonProject | /example24.py | 659 | 4.375 | 4 | import sys
total = len(sys.argv) - 1 # because we put 3 args
print("Total number of args {}".format(total))
if total > 2:
print("Too many arguments")
elif total < 2:
print("Too less arguments")
elif total == 2:
print("It's correct")
arg1 = int(sys.argv[1])
arg2 = int(sys.argv[2])
if arg1 ... | true |
1688c93855bda769c0e21a5cbfb463cfe3cc0299 | JimVargas5/LC101-Crypto | /caesar.py | 798 | 4.25 | 4 | #Jim Vargas caesar
import string
from helpers import rotate_character, alphabet_position
from sys import argv, exit
def encrypt(text, rot):
'''Encrypts a text based on a pseudo ord circle caesar style'''
NewString = ""
for character in text:
NewChar = rotate_character(character, rot)
NewStr... | true |
b211b888702bbb1ebed8b6ee2b21fec7329a7b59 | deyoung1028/Python | /to_do_list.py | 1,738 | 4.625 | 5 | #In this assignment you are going to create a TODO app. When the app starts it should present user with the following menu:
#Press 1 to add task
#Press 2 to delete task (HARD MODE)
#Press 3 to view all tasks
#Press q to quit
#The user should only be allowed to quit when they press 'q'.
#Add Task:
#Ask the user f... | true |
e41796d392658024498869143c8b8879a7916968 | deyoung1028/Python | /dictionary.py | 487 | 4.21875 | 4 | #Take inputs for firstname and lastname and then create a dictionary with your first and last name.
#Finally, print out the contents of the dictionary on the screen in the following format.
users=[]
while True:
first = input("Enter first name:")
last = input("Enter last name:")
user = {"first" ... | true |
74dee8921f4db66c458a0c53cd08cb54a2d1ba63 | KritikRawal/Lab_Exercise-all | /4.l.2.py | 322 | 4.21875 | 4 | """ Write a Python program to multiplies all the items in a list"""
total=1
list1 = [11, 5, 17, 18, 23]
# Iterate each element in list
# and add them in variable total
for ele in range(0, len(list1)):
total = total * list1[ele]
# printing total value
print("product of all elements in given list: ", tota... | true |
d71d9e8c02f405e55e493d1955451c12d50f7b9b | KritikRawal/Lab_Exercise-all | /3.11.py | 220 | 4.28125 | 4 | """ find the factorial of a number using functions"""
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n - 1)
num = int(input('enter the number'))
print(factorial)
| true |
53b8278af9a4a98b4de820d91054d80e9f1247f4 | KritikRawal/Lab_Exercise-all | /3.8.py | 393 | 4.125 | 4 | """takes a number as a parameter and check the number is prime or not"""
def is_prime(num):
for i in range(2, num):
if num % i == 0:
return False
return True
print('Start')
val = int(input('Enter the number to check prime:\n'))
ans = is_prime(val)
if ans:
print(val,... | true |
ae6ae8cfe7e655b1ffc9617eb8d87480a97e8f27 | KritikRawal/Lab_Exercise-all | /4.2.py | 635 | 4.4375 | 4 | """. Write a Python program to convert temperatures to and from celsius,
fahrenheit.
C = (5/9) * (F - 32)"""
print("Choose the conversion: ")
print(" [c] for celsius to fahrenheit")
print(" [f] for fahrenheit to celsius")
ans = input()
conversion = 0
cs = ""
if ans == "c":
ans = "Celsius"
elif an... | true |
b9e75d0b9d9605330c54818d1dd643cc764032cf | KritikRawal/Lab_Exercise-all | /2.5.py | 277 | 4.21875 | 4 | """For given integer x,
print ‘True’ if it is positive,
print ‘False’ if it is negative and
print ‘zero’ if it is 0"""
x = int(input("Enter a number: "))
if x > 0:
print('positive')
elif x<0:
print('negative')
else:
print('zero') | true |
99e3a484814475a5ccc0627f5d875507a5213b0c | Mattias-/interview_bootcamp | /python/fizzbuzz.py | 520 | 4.15625 | 4 |
# Using any language you want (even pseudocode), write a program or subroutine
# that prints the numbers from 1 to 100, each number on a line, except for every
# third number write "fizz", for every fifth number write "buzz", and if a
# number is divisible by both 3 and 5 write "fizzbuzz".
def fb():
for i in xr... | true |
1aae789149cce977556e11683e898dc039bdb9ad | derek-baker/Random-CS-Stuff | /python/SetCover/Implementation.py | 1,542 | 4.1875 | 4 | # INSPIRED BY: http://www.martinbroadhurst.com/greedy-set-cover-in-python.html
# def test_that_subset_elements_contain_universe(universe, elements):
# if elements != universe:
# return False
# return True
def compute_set_cover(universe, subsets):
# Get distinct set of elements from all subsets
... | true |
e74add4e61a90087bb085b51a8734a718fd554f7 | sador23/cc_assignment | /helloworld.py | 602 | 4.28125 | 4 | '''The program asks for a string input, and welcomes the person, or welcomes the world if nothing was given.'''
def inputname():
'''Keeps asking until a string is inputted'''
while True:
try:
name=input("Please enter your name!")
int(name)
print("This is not a string... | true |
2abe2c2de6d54d9a44b3abb3fc03c88997840e61 | maria1226/Basics_Python | /aquarium.py | 801 | 4.53125 | 5 | # For his birthday, Lubomir received an aquarium in the shape of a parallelepiped. You have to calculate how much
# liters of water will collect the aquarium if it is known that a certain percentage of its capacity is occupied by sand,
# plants, heater and pump.
# Its dimensions - length, width and height in centimete... | true |
56a13bb22f6d53ef4e149941d2d4119cc8d4edd3 | lagzda/Exercises | /PythonEx/intersection.py | 450 | 4.125 | 4 | def intersection(arr1, arr2):
#This is so we always use the smallest array
if len(arr1) > len(arr2): arr1, arr2 = arr2, arr1
#Initialise the intersection holder
inter = []
for i in arr1:
#If it is an intersection and avoid duplicates
if i in arr2 and i not in inter:
... | true |
2c9da507053689dee6cc34724324521983ea0c8c | miroslavgasparek/python_intro | /numpy_practice.py | 1,834 | 4.125 | 4 | # 21 February 2018 Miroslav Gasparek
# Practice with NumPy
import numpy as np
# Practice 1
# Generate array of 0 to 10
my_ar1 = np.arange(0,11,dtype='float')
print(my_ar1)
my_ar2 = np.linspace(0,10,11,dtype='float')
print(my_ar2)
# Practice 2
# Load in data
xa_high = np.loadtxt('data/xa_high_food.csv',comments='#')... | true |
877150ed0d4fb9185a633ee923daee0ba3d745e4 | nmessa/Raspberry-Pi | /Programming/SimplePython/name4.py | 550 | 4.125 | 4 | # iteration (looping) with selection (conditions)
again = True
while again:
name = raw_input("What is your name? ")
print "Hello", name
age = int(raw_input("How old are you? "))
newage = age + 1
print "Next year you will be ", newage
if age>=5 and age<19:
print "You are still in school... | true |
cd0c13a1013724e1ec7920a706ee52e2aa0e9a96 | Teslothorcha/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 411 | 4.15625 | 4 | #!/usr/bin/python3
"""
This function will add two values
casted values if necessary (int/float)
and return the addition
"""
def add_integer(a, b=98):
"""
check if args are ints to add'em'
"""
if not isinstance(a, (int, float)):
raise TypeError("a must be an integer")
if not isinstance(b, (... | true |
5e6e2e5e3d29dc46c9e5a9e7bc49a5172fbbb3cb | wbsth/mooc-da | /part01-e07_areas_of_shapes/src/areas_of_shapes.py | 935 | 4.1875 | 4 | #!/usr/bin/env python3
import math
def main():
while True:
shape = input('Choose a shape (triangle, rectangle, circle): ')
if shape == '':
break
else:
if shape == 'rectangle':
r_width = int(input("Give width of the rectangle: "))
r_h... | true |
d3e64c5bfe6b5508c458a2bc76e40fa6ef0f4019 | nasrinsultana014/HackerRank-Python-Problems | /Solutions/Problem14.py | 536 | 4.21875 | 4 | def swap_case(s):
characters = list(s)
convertedCharacters = []
convertedStr = ""
for i in range(len(characters)):
if characters[i].isupper():
convertedCharacters.append(characters[i].lower())
elif characters[i].islower():
convertedCharacters.append(characters[i]... | true |
0f28ba6d84069ffabf1a733ca4f4980c28674290 | ngoc123321/nguyentuanngoc-c4e-gen30 | /session2/baiq.py | 480 | 4.15625 | 4 | weight = float(input('Your weight in kilos: ')) # <=== 79
height = float(input('Your height in meters: ')) # <=== 1.75
BMI = weight / height ** 2
BMI = round(BMI, 1)
if BMI < 16: result = 'Severely underweight.'
elif 16 < BMI <= 18.5: result = 'Underweight.'
elif 18.5 < BMI <= 25: result = 'Normal.'
elif 25 < BMI <= 3... | true |
d63f3014189730c8afbe7f91add852ef729e22f0 | inwk6312fall2019/dss-Tarang97 | /Chapter12-Tuples/Ex12.2.py | 1,579 | 4.21875 | 4 | fin = open('words.txt')
# is_anagram() will take a single text from 'words.txt', sorts it and lower the cases and
# append the original word in the list which will be the default value of sorted_dict() values;
# but, the sorted_word will be in sorted_dict() dictionary along with its value.
def is_anagram(text):
... | true |
c65858019b12bc00cc9733a9fa2de5fd5dda8d14 | asadali08/asadali08 | /Dictionaries.py | 1,662 | 4.375 | 4 | # Chapter 9. Dictionaries
# Dictionary is like a set of items with any label without any organization
purse = dict()# Right now, purse is an empty variable of dictionary category
purse['money'] = 12
purse['candy'] = 3
purse['tissues'] = 75
print(purse)
print(purse['candy'])
purse['money'] = purse['money'] + 8... | true |
f8327a56682bd0b9e4057defb9b016fd0b56afdd | karagdon/pypy | /48.py | 671 | 4.1875 | 4 | # lexicon = allwoed owrds list
stuff = raw_input('> ')
words = stuff.split()
print "A TUPLE IS SIMPLY A LIST YOU CANT MODIFY"
# lexicon tuples
first_word = ('verb', 'go')
second_word = ('direction', 'north')
third_word = ('direction', 'west')
sentence = [first_word, second_word, third_word]
def convert_numbers(s):
... | true |
80a5137b9ab2d2ec77805ef71c2513d8fcdf81a0 | karagdon/pypy | /Python_codeAcademy/binary_rep.py | 1,384 | 4.625 | 5 | #bitwise represention
#Base 2:
print bin(1)
#base8
print hex(7)
#base 16
print oct(11)
#BITWISE OPERATORS#
# AND FUNCTION, A&B
# 0b1110
# 0b0101
# 0b0100
print "AND FUNCTION, A&B"
print "======================\n"
print "bin(0b1110 & 0b101)"
print "= ",bin(0b1110&0b101)
# THIS OR THAT, A|B
#The bitwise OR (|... | true |
729099b198e045ce3cfe0904f325b62ce3e3dc5e | karagdon/pypy | /diveintopython/707.py | 579 | 4.28125 | 4 | ### Regex Summary
# ^ matches
# $ matches the end of a string
# \b matches a word boundary
# \d matches any numeric digit
# \D matches any non-numeric character
# x? matches an optional x character (in other words, it matches an x zero or one times)
# x* matches x zero or more times
# x+ matches x one or more ti... | true |
bd00c3566cf764ca82bba1a4af1090581a84d50f | f1uk3r/Daily-Programmer | /Problem-3/dp3-caeser-cipher.py | 715 | 4.1875 | 4 | def translateMessage(do, message, key):
if do == "d":
key = -key
transMessage = ""
for symbol in message:
if symbol.isalpha():
num = ord(symbol)
num += key
if symbol.isupper():
if num > ord("Z"):
num -= 26
elif num < ord("A"):
num += 26
if symbol.islower():
if num > ord("z"):
... | true |
e2b0a7d7bc76ef3739eace98f62081e78df24b67 | f1uk3r/Daily-Programmer | /Problem-11/Easy/tell-day-from-date.py | 540 | 4.5 | 4 | # python 3
# tell-day-from-date.py #give arguments for date returns day of week
# The program should take three arguments. The first will be a day,
# the second will be month, and the third will be year. Then,
# your program should compute the day of the week that date will fall on.
import datetime
import calendar... | true |
8d888e53b71da82ae029c0ffc4563edc84b8283d | EdwardMoseley/HackerRank | /Python/INTRO Find The Second Largest Number.py | 661 | 4.15625 | 4 | #!/bin/python3
import sys
"""
https://www.hackerrank.com/challenges/find-second-maximum-number-in-a-list
Find the second largest number in a list
"""
#Pull the first integer-- we don't need it
junk = input()
def secondLargest(arg):
dat = []
for line in arg:
dat.append(line)
... | true |
bbe8b6100246aa2f58fca457929827a0897e9be5 | arickels11/Module4Topic3 | /topic_3_main/main_calc.py | 1,637 | 4.15625 | 4 | """CIS 189
Author: Alex Rickels
Module 4 Topic 3 Assignment"""
# You may apply one $5 or $10 cash off per order.
# The second is percent discount coupons for 10%, 15%, or 20% off.
# If you have cash-off coupons, those must be applied first, then apply the percent discount coupons on the pre-tax
# Then you add tax at... | true |
27006f8290968a5d89a8d0d25355538212718075 | Manny-Ventura/FFC-Beginner-Python-Projects | /madlibs.py | 1,733 | 4.1875 | 4 | # string concatenation (akka how to put strings together)
# # suppose we want to create a string that says "subscribe to ____ "
# youtuber = "Manny Ventura" # some string variable
# # a few ways...
# print("Subscribe to " + youtuber)
# print("Subscribe to {}".format(youtuber))
# print(f"subscribe to {youtuber}")
adj ... | true |
de25e31fa817bc6347566c021edc50f1868de959 | gohjunyi/RegEx | /google_ex.py | 1,167 | 4.125 | 4 | import re
string = 'an example word:cat!!'
match = re.search(r'word:\w\w\w', string)
# If-statement after search() tests if it succeeded
if match:
print('found', match.group()) # 'found word:cat')
else:
print('did not find')
# i+ = one or more i's, as many as possible.
match = re.search(r'pi+', 'piiig') # fo... | true |
f01d7fab6569e318399eee144b7310d39433d061 | ammalik221/Python-Data-Structures | /Collections/Queues_using_queue_module.py | 411 | 4.1875 | 4 | """
Queues Implementation in Python 3.0 using deque module.
For implementations from scratch, check out the other files in this repository.
"""
from collections import deque
# test cases
# make a deque
q = deque()
# add elements
q.append(20)
q.append(30)
q.append(40)
# output is - 10 20 30 40
print(q)
# remove el... | true |
73c2bcf27da231afe7d9af4425683c006799e7a9 | razzanamani/pythonCalculator | /calculator.py | 1,515 | 4.375 | 4 | #!usr/bin/python
#Interpreter: Python3
#Program to create a functioning calculator
def welcome():
print('Welcome to the Calculator.')
def again():
again_input = input('''
Do you want to calculate again?
Press Y for YES and N for NO
''')
# if user types Y, run the calculate() function
if again_input == 'Y':
c... | true |
ee1e7bff3095782f4886eeefc0558543c091ddc6 | williamsyb/mycookbook | /thread_prac/different_way_kill_thread/de04.py | 1,153 | 4.59375 | 5 | # Python program killing
# a thread using multiprocessing
# module
"""
Though the interface of the two modules is similar, the two modules have very different implementations.
All the threads share global variables, whereas processes are completely separate from each other.
Hence, killing processes is much safer as co... | true |
353a3606af9aa9b5c5065edaa2e35d88f9e8ec5f | Imsurajkr/Cod001 | /challenge2.py | 662 | 4.1875 | 4 | #!/usr/bin/python3
import random
highestNumber = 10
answer = random.randint(1, highestNumber)
print("Enter the number betweeen 1 and {}".format(highestNumber))
guess = 0 #initialize to any number outside of the range
while guess != answer:
guess = int(input())
if guess > answer:
print("please Select Lo... | true |
6ca787eac5185c966f539079a8d2b890d9dc6447 | OldPanda/The-Analysis-of-Algorithms-Code | /Chapter_2/2.4.py | 897 | 4.15625 | 4 | """
Random Hashing:
Data structure: a key array X with entries x_i for 0 <= i <= N-1 and a corresponding record array R.
Initial conditions: the number of entries, k, is zero and each key location, x_i, contains the value empty, a special value that is not the value of any key.
Input: a query, q.
Output: a loca... | true |
2ca5b9fd677edf64a50c6687803c91b721bee140 | basakmugdha/Python-Workout | /1. Numeric Types/Excercise 1 (Number Guessing Game)/Ex1c_word_GG.py | 848 | 4.375 | 4 | #Excercise 1 beyond 3: Word Guessing Game
from random_word import RandomWords
def guessing_game():
'''returns a random integer between 1 and 100'''
r = RandomWords()
return r.get_random_word()
if __name__ == '__main__':
print('Hmmmm.... let me pick a word')
word = guessing_game()
gu... | true |
c26c3fa52692454bd47cfab92253715ed461f4f2 | DiegoRmsR/holbertonschool-higher_level_programming | /0x03-python-data_structures/3-print_reversed_list_integer.py | 223 | 4.28125 | 4 | #!/usr/bin/python3
def print_reversed_list_integer(my_list=[]):
if not my_list:
pass
else:
for list_reverse in reversed(my_list):
str = "{:d}"
print(str.format(list_reverse))
| true |
8ba63fdd070ef490570285c17d8669b8d8ffb5b0 | lukelu389/programming-class | /python_demo_programs/2020/prime_number.py | 273 | 4.375 | 4 | # write a python program to check if a number is prime or not
number = int(input('enter a number:'))
n = 1
counter = 0
while n <= number:
if number % n == 0:
counter += 1
n += 1
if counter > 2:
print('not prime number')
else:
print('prime number') | true |
3404c6cc7af2350bf12592921226a9f4a87da618 | lukelu389/programming-class | /python_demo_programs/2021/example_20210319.py | 1,529 | 4.1875 | 4 | # s = 'abcdefgh'
# print(s[0:2])
# print(s[:2]) # implicitly start at 0
# print(s[3:]) # implicitly end at the end
#
# # slice from index 4 to the end
# print(s[4:])
# to achieve the conditional, need to use if keyword
# a = 6
# b = 5
# if b > a:
# print('inside if statement')
# print('b is bigger than a')
# ... | true |
1d4bac21899ddd993ad41cdf80a0c2ad350b8104 | lukelu389/programming-class | /python_demo_programs/2021/example_20210815.py | 1,644 | 4.1875 | 4 | # class Person:
# def __init__(self, name):
# self.name = name
# def method1(self):
# return 'hello'
# p1 = Person('jerry')
# print(p1.name)
# Person.method1()
# class = variables + methods
# variable: static variable vs instance variable
# method: static method vs instance method
# class is... | true |
6d7f89a6f38bcb3765ff3e6f5a954bfed6b27f3c | lukelu389/programming-class | /python_demo_programs/2020/factorial.py | 231 | 4.15625 | 4 |
# use a loop to calculate n*(n-1)*(n-2)*(n-3)*...2*1,
# and return the result
def factorial(n):
result = 1
while n > 0:
result = result * n
n -= 1
return result
print(factorial(5))
print(factorial(3)) | true |
ea53f0ecbeee4c3c1a35d5a2d2569b8a70cf4ea2 | lukelu389/programming-class | /python_demo_programs/2020/example_20201018.py | 1,389 | 4.125 | 4 | # homework
# write a python function takes two lists as input, check if one list contains another list
# [1, 2, 3] [1, 2] -> true
# [1] [1, 2, 3] -> true
# [1, 2] [1, 3] -> false
def contain(list1, list2):
# loop through list1 check if each element in list1 is also in list2
list2_contains_list1 = True
for... | true |
9e63c534debc5b8bb2adcfd7493ce18e8acd1bf7 | lukelu389/programming-class | /python_demo_programs/2020/example_20201025.py | 1,532 | 4.25 | 4 | # # write a python function that takes a list and a int, check if list contains any two values that diff of the two values
# # is the input int
# # [1, 2, 3] 1 -> true
# # [1, 2, 3] 4 -> false
#
# def find_diff(list, target):
# for i in list:
# for j in list:
# if j - i == target:
# ... | true |
a0b7bbca5f8d4cbd1638a54e0e7c5d78302139f8 | vijaykanth1729/Python-Programs-Interview-Purpose | /list_remove_duplicates.py | 776 | 4.3125 | 4 | '''
Write a program (function!) that takes a list and returns a new
list that contains all the elements of the first list minus all the duplicates.
Extras:
Write two different functions to do this - one using a loop and constructing a
list, and another using sets.
Go back and do Exercise 5 using sets, and write the so... | true |
bb3c2b979426ab217b7cf3bbdadb12d4c8aa2e05 | ThtGuyBro/Python-sample | /Dict.py | 307 | 4.125 | 4 | words = {"favorite dessert": "apple pie","never eat": "scallop","always have" : "parachute","don't have" :"accident","do this" : "fare","bug" : "flea"}
print(words['bug'])
words['parachute']= 'water'
words['oar']= 'girrafe'
del words['never eat']
for key, value in words.items():
print(key)
| true |
8320e270cc0ef7f8767336dfcb0dcf7ffe538e01 | tocodeil/webinar-live-demos | /20200326-clojure/patterns/04_recursion.py | 658 | 4.15625 | 4 | """
Iteration (looping) in functional languages is usually accomplished
via recursion.
Recursive functions invoke themselves,
letting an operation be repeated until it reaches the base case.
"""
import os.path
# Iterative code
def find_available_filename_iter(base):
i = 0
while os.path.exists(f"{base}_{i}"):... | true |
fc0d283efec47c1f9a4b19eeeff42ba58db258c7 | EdmondTongyou/Rock-Paper-Scissors | /main.py | 2,479 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
Edmond Tongyou
CPSC 223P-01
Tues March 9 14:47:33 2021
tongyouedmond@fullerton.edu
"""
# Importing random for randint()
import random
computerScore = 0
ties = 0
userScore = 0
computerChoice = ""
userChoice = ""
# Loops until the exit condition (Q) is met otherwise keeps asking for
# on... | true |
ca9040e2f67a9ef6e1e15e9b5fa73c8df6295877 | mileuc/100-days-of-python | /Day 10: Calculator/main.py | 1,544 | 4.3125 | 4 | from art import logo
from replit import clear
def calculate(operation, first_num, second_num):
"""Takes two input numbers, a chosen mathematical operation, and performs the operation on the two numbers and returns the output."""
if operation == '+':
output = first_num + second_num
return output
elif oper... | true |
7e6caaea40c2ca56d00cf95dce934fb338a55ca1 | dlingerfelt/DSC-510-Fall2019 | /FRAKSO_MOHAMMED_DSC51/loops-week5.py | 2,983 | 4.53125 | 5 | '''
File: Loops.py
Name: Mohammed A. Frakso
Date: 12/01/2020
Course: DSC_510 - Introduction to Programming
Desc: This program will contain a variety of loops and functions:
The program will add, subtract, multiply, divide two numbers and provide the average of multiple numbers input by the user.
Define a functio... | true |
88333bcf49ae0f01c6f7d4cca37c1dae5ddb64a2 | dlingerfelt/DSC-510-Fall2019 | /JALADI_DSC510/final/WeatherDisplay.py | 1,791 | 4.34375 | 4 | # File : WeatherDisplay.py
# Name : Pradeep Jaladi
# Date : 02/22/2020
# Course : DSC-510 - Introduction to Programming
# Desc : Weather Display class displays the weather details to output.
class WeatherDisplay:
def __init__(self, desc, city, country, temp, feels_like, min_temp, max_temp, lat, lon, wind)... | true |
433d5b3ed946f1f84893a9eed708b49e902af6c0 | dlingerfelt/DSC-510-Fall2019 | /NERALLA_DSC510/NERALLA_DSC510_WEEK11.py | 2,521 | 4.15625 | 4 | '''
File: NERALLA_DSC510_WEEK10.py
Name: Ravindra Neralla
Course:DSC510-T303
Date:02/23/2020
Description: This program is to create a simple cash register program.
The program will have one class called CashRegister.
The program will have an instance method called addItem which takes one parameter for price. The method... | true |
78eee39d5b2e07f640f8be3968acdec0b7c8e13f | dlingerfelt/DSC-510-Fall2019 | /Safari_Edris_DSC510/Week4/Safari_DSC510_Cable_Cost.py | 1,951 | 4.4375 | 4 | # File : Safari_DSC510_Cable_Cost.py
# Name:Edris Safari
# Date:9/18/2019
# Course: DSC510 - Introduction To Programming
# Desc: Get name of company and length in feet of fiber cable. compute cost at $.87 per foot. display result in recipt format.
# Usage: Provide input when prompted.
def welcome_screen():
"""Pr... | true |
d2587b87036af1d39d478e5db8c6d03b19c6da83 | dlingerfelt/DSC-510-Fall2019 | /SMILINSKAS_DSC510/Temperatures.py | 1,290 | 4.21875 | 4 | # File: Temperatures.py
# Name: Vilius Smilinskas
# Date: 1/18/2020
# Course: DSC510: Introduction to Programming
# Desc: Program will collect multiple temperature inputs, find the max and min values and present the total
# number of values in the list
# Usage: Input information when prompted, input go to retriev... | true |
7faffa27e0944548717be676c521fcb8ed1653a8 | dlingerfelt/DSC-510-Fall2019 | /FRAKSO_MOHAMMED_DSC51/week6-lists.py | 1,257 | 4.46875 | 4 | '''
File: lists.py
Name: Mohammed A. Frakso
Date: 19/01/2020
Course: DSC_510 - Introduction to Programming
Desc: This program will work with lists:
The program will contains a list of temperatures, it will populate the list based upon user input.
The program will determine the number of temperatures in the prog... | true |
42d37509986bc3233ab711cef2496ab4fa17602a | dlingerfelt/DSC-510-Fall2019 | /Ndingwan_DSC510/week4.py | 2,921 | 4.28125 | 4 | # File: week4.py
# Name: Awah Ndingwan
# Date: 09/17/2019
# Desc: Program calculates total cost by multiplying length of feet by cost per feet
# Usage: This program receives input from the user and calculates total cost by multiplying the number of feet
# by the cost per feet. Finally the program returns a summary of t... | true |
8c70251443a384255c610a8a96d4977c5da28947 | dlingerfelt/DSC-510-Fall2019 | /JALADI_DSC510/TEMPERATURE_OPERATIONS.py | 1,536 | 4.53125 | 5 | # File : MATH_OPERATIONS.py
# Name : Pradeep Jaladi
# Date : 01/11/2020
# Course : DSC-510 - Introduction to Programming
# Assignment :
# Program :
# Create an empty list called temperatures.
# Allow the user to input a series of temperatures along with a sentinel value which will stop the user input.
#... | true |
f5428333663e7da9d39bdff3e25f6a34c07ebd08 | dlingerfelt/DSC-510-Fall2019 | /Steen_DSC510/Assignment 3.1 - Jonathan Steen.py | 1,186 | 4.34375 | 4 | # File: Assignment 3.1 - Jonathan Steen.py
# Name: Jonathan Steen
# Date: 12/9/2019
# Course: DSC510 - Introduction to Programing
# Desc: Program calculates cost of fiber optic installation.
# Usage: The program gets company name,
# number of feet of fiber optic cable, calculate
# installation cost, bu... | true |
af093e824555df86dc56d2b1b581270fd1671d1c | dlingerfelt/DSC-510-Fall2019 | /Stone_DSC510/Assignment2_1/Assignment2_1.py | 751 | 4.21875 | 4 | # 2.1 Programming Assignment Calculate Cost of Cabling
# Name: Zachary Stone
# File: Assignment 2.1.py
# Date: 09/08/2019
# Course: DSC510-Introduction to Programming
# Greeting
print('Welcome to the ABC Cabling Company')
# Get Company Name
companyName = input('What is the name of you company?\n')
# Get Num of feet
fe... | true |
edc28c6d0a7bd72d9a875d7716f8957874455fd0 | dlingerfelt/DSC-510-Fall2019 | /Steen_DSC510/Assignment 4.1 - Jonathan Steen.py | 1,364 | 4.15625 | 4 | # File: Assignment 4.1 - Jonathan Steen.py
# Name: Jonathan Steen
# Date: 12/17/2019
# Course: DSC510 - Introduction to Programing
# Desc: Program calculates cost of fiber optic installation.
# Usage: The program gets company name,
# number of feet of fiber optic cable, calculate
# installation ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.