blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
fd2958044308c991ea843b73987860bb7fc75a3b | Anushree-J-S/Launchpad-Assignments | /problem1.py | 412 | 4.15625 | 4 | #Create a program that asks the user to enter their name and age.
#Print out a message addressed to them that tells them the year that they will turn 100 years old
print("Code for problem 1")
from datetime import datetime
name=input("Enter your name:")
age=int(input("Enter your age:"))
year=int((100-age)... | true |
2c07ea5764d7173d72c7b85a1d0622a6a7c8e145 | vinodh1988/python-code-essentials | /conditional.py | 436 | 4.15625 | 4 |
name=input('enter you name >> ')
print(len(name))
if(len(name)>=5):
print('Valid name it has more than 4 characters')
print('We shall store it in the database')
elif(len(name)==3 or len(name)==4):
print('type confirm to store it into the database >>')
if 'confirm'==input():
print('stored in ... | true |
e3c217f79478ea89de35f9f7b761d19fbfdde837 | x223/cs11-student-work-Karen-Gil | /Countdown2.py | 438 | 4.28125 | 4 | countdown = input('pick a number')
number= countdown
while number>0:
#number has to be grater than zero in order for it to countdown duh!!!
print number
number= number-1
#In order for there to be a countdown it has to be number-1
print('BOOM!!!')
# I origanaly wrote print boom as showen below but it pri... | true |
0da6b491db0b5599895b81f1fd57a72df49b1393 | Farheen2302/ds_algo | /algorithms/sorting/quicksort.py | 1,223 | 4.25 | 4 | def quicksort(arr, start, end):
if start < end:
pivot = _quicksort(arr, start, end)
left = quicksort(arr, 0, pivot - 1)
right = quicksort(arr, pivot + 1, end)
return arr
def _quicksort(arr, start, end):
pivot = start
left = start + 1
right = end
done = False
while n... | true |
0bb37602e0531c8d9340ce0f9335d817c0730b97 | donato/notes | /interviews/2017/practice/linked-list-palindrome.py | 1,265 | 4.15625 | 4 | def find_middle(head):
"""FInd meddle of linked list using 2 runner strategy and return if it's an odd length list
return middle_node, is_odd(Bool)
"""
r1 = head
r2 = head
while r2.next:
if not r2.next.next:
return r1, False
r1 = r1.next
r2 = r2.next.next
... | true |
4701dc2609fcbc88935c0a52dca736fd40fa5099 | Ricardo-Sillas/Project-1 | /Main.py | 964 | 4.21875 | 4 | import hashlib
def hash_with_sha256(str):
hash_object = hashlib.sha256(str.encode('utf-8'))
hex_dig = hash_object.hexdigest()
return hex_dig
# starts numbers off with length 3, increments the number by one, then increments length by one at the end of that length
def getNum(s, n):
if len(s) == n:
check(... | true |
09f75de95ac1f64a6ffd3b73e803b32ed8a209a8 | rakeshsukla53/interview-preparation | /Rakesh/python-basics/call_by_reference_in_python.py | 1,081 | 4.28125 | 4 |
def foo(x):
x = 'another value' # here x is another name bind which points to string variable 'another value'
print x
bar = 'some value'
foo(bar)
print bar # bar is named variable and is pointing to a string object
# string objects are immutable, the value cannot be modified
# you can not pass a simple p... | true |
de4fc062a33d209172ed71d02074dda15ebbe5d4 | rakeshsukla53/interview-preparation | /Rakesh/trees/Symmetric_Tree_optimized.py | 888 | 4.28125 | 4 |
# for this method I am going to use the reverse binary tree method to check for symmetric tree
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def __init__(self):
self.... | true |
dc53ce7c76f9b149441aeda751214149d8933c17 | rakeshsukla53/interview-preparation | /Rakesh/python-iterators/remove_while_iteration.py | 636 | 4.125 | 4 | __author__ = 'rakesh'
somelist = range(10)
for x in somelist:
somelist.remove(x) #so here you are modifying the main list which you should not be doing
print somelist
somelist = range(10)
for x in somelist[:]: #Because the second one iterates over a copy of the list. So when you modify the original list, you do... | true |
d9d3972659395307fb5353071b3615a0ad82c1bc | rakeshsukla53/interview-preparation | /Rakesh/Google-interview/breeding_like_rabbits_optimized_method.py | 2,970 | 4.5 | 4 | __author__ = 'rakesh'
#here we have to know about memoization
#Idea 1 - To sabe the result in some variables ---but it is not feasible. Fibonacci can be done since only two variables
#are required. Also in the memoization part there is only recursion process not all.
#Idea 2 - Use some kind of hash table here, but i... | true |
1b1e945ef82db250c50dd635c5da0a86a8ec32fc | rakeshsukla53/interview-preparation | /Rakesh/Common-interview-problems/product of array except self.py | 912 | 4.15625 | 4 |
class Solution(object):
def productExceptSelf(self, nums):
"""
:type nums: List[int]
:rtype: List[int]
Logic :
You will use two loops one going from left to right, and other from right to left
for example if a = [1, 2, 3, 4]
Going from left -> a = [1, 1, 2, ... | true |
23ca1215a474d6a40ac0c93df2446b5475adce9a | rakeshsukla53/interview-preparation | /Rakesh/Common-interview-problems/Ordered_Dict.py | 1,795 | 4.21875 | 4 | __author__ = 'rakesh'
#What is orderedDict
#An OrderedDict is a dict that remembers the order that keys were first inserted. If a new entry overwrites an existing entry, the original insertion position is left unchanged. Deleting an entry and reinserting it will move it to the end.
from collections import OrderedDict... | true |
dcb5dc0d8b77109893f6c8f0446daf75e4cf57f8 | rakeshsukla53/interview-preparation | /Rakesh/Natural Language Processing/word_tokenize.py | 750 | 4.1875 | 4 | __author__ = 'rakesh'
#http://pythonprogramming.net/tokenizing-words-sentences-nltk-tutorial/
from nltk.tokenize import sent_tokenize, word_tokenize
EXAMPLE_TEXT = "Hello Mr. Smith, how are you doing today? The weather is great, and Python is awesome. The sky is pinkish-blue. You shouldn't eat cardboard."
print(sent... | true |
6d3aba17b75e3eff3b706bc6ec4bdf1b583dc0a8 | katiemharding/ProgrammingForBiologyCourse2019 | /problemsets/PythonProblemSets/positiveOrNegative.py | 996 | 4.59375 | 5 | #!/usr/bin/env python3
import sys
# for testing assign a number to a value
unknown_number = int(sys.argv[1])
# first test if it is positive
if unknown_number>0:
print(unknown_number, "is positive")
if unknown_number > 50:
# modulo (%) returns the remainder. allows testing if divisible by
if unknown_number%3 == 0:
... | true |
c97df9692c0d772e8cef6a60bdb23a59ba803ccd | sxd7/p_ython | /python.py | 413 | 4.21875 | 4 | Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> import math
>>> radius=float(input("enter the radius of the circle:"))
enter the radius of the circle:5
>>> area=math.pi*radius*radius;
>>> pr... | true |
222f287965120511ecb52663994e286d2752d363 | PradeepNingaiah/python-assginments | /hemanth kumar python assginment/14.exception.py | 1,734 | 4.5625 | 5 |
#1. Write a program to generate Arithmetic Exception without exception handling
try:
a = 10/0
print (a)
except ArithmeticError:
print ("This statement is raising an arithmetic exception.")
else:
print ("Success.")
#--------------------------------------------------------------------------... | true |
9bcaa72b193d3b5ce12db67faffd751c3f1cc7c5 | girisagar46/KodoMathOps | /kodomath/mathops/quiz_service.py | 1,377 | 4.15625 | 4 | from decimal import Decimal
from asteval import Interpreter
class SubmissionEvaluator:
"""A helper class to evaluate if submission if correct or not.
"""
def __init__(self, expression, submitted_result):
self.expression = expression
self.submitted_result = submitted_result
# https:... | true |
493cc5ee3132d01c05cca6495738e3e4f6ab1436 | rbodduluru/PythonCodes | /Duplicatenumsinlist.py | 448 | 4.25 | 4 | # #!/usr/bin/python
# Python program to find the duplicate numbers in the list of numbers
def finddup(myList):
for i in set(myList):
if myList.count(i) > 1:
print "Duplicate number(s) in the list : %i"%i
if __name__ == '__main__':
myList = []
maxNumbers = 10
while len(myList)... | true |
20c489dd909c4846446ecf15b8169f6a5fe9da13 | dwambia/100daysofhacking | /Tiplator.py | 565 | 4.28125 | 4 | #Simple python code to calculate amount a user is to tip
total_bill = input("What is your total bill? ")
#ignore the $ sign if user inputs
total_bill= total_bill.replace("$","")
#convert users bill to float
total_bill=float(total_bill)
print(total_bill)
#list of possible tips calculation
tip_1= 0.15*total_bill
tip_2... | true |
b7a4c138b9106c64d6db33f53e6cd0b5b35e5648 | olotintemitope/Algo-Practice | /quick_sort.py | 1,732 | 4.125 | 4 | def quick_sort(lists):
lists_length = len(lists)
if lists_length > 2:
current_position = 0
""" Partition the lists """
for index in range(1, lists_length):
pivot = lists[0]
if lists[index] <= pivot:
current_position += 1
swap = lis... | true |
3f749cb2850ed64d6f566e23b75c1df30023bab7 | Divyalok123/CN_Data_Structures_And_Algorithms | /more_problems/Test2_P2_Problems/Minimum_Length_Word.py | 298 | 4.28125 | 4 | #Given a string S (that can contain multiple words), you need to find the word which has minimum length.
string = input()
newArr = string.split(" ")
result = newArr[0]
for i in range(1, len(newArr)):
if(len(newArr[i]) < len(result)):
result = newArr[i]
print(result)
| true |
f312341382425fcd01f4a489b0fc7e615ac3ba22 | diek/backtobasics | /trade_apple_stocks.py | 1,541 | 4.1875 | 4 |
'''Suppose we could access yesterday's stock prices as a list, where:
The indices are the time in minutes past trade opening time, which was 9:30am local time.
The values are the price in dollars of Apple stock at that time.
So if the stock cost $500 at 10:30am, stock_prices_yesterday[60] = 500.
Write an efficient f... | true |
a0e534755de438b61477b6e823fca6069a07aeb4 | beggerss/algorithms | /Sort/quick.py | 1,410 | 4.1875 | 4 | #!/usr/bin/python2
# Author: Ben Eggers (ben@beneggers.com)
import time
import numpy as np
import matplotlib.pyplot as plt
import itertools
# Implementation of a quicksort in Python.
def main():
base = 10000
x_points = []
y_points = []
for x in range(1, 20):
arr = [np.random.randint(0, base*x) for k in range(b... | true |
3c50a395000e9474c8be1cd4233e55137df20293 | jscs9/assignments | /moves.py | 1,681 | 4.1875 | 4 | import random as rand
def request_moves(how_many):
'''
Generates a string representing moves for a monster in a video game.
how_many: number of move segments to be generated. Each segment occurs in a specific
direction with a distance of between 1 and 5 steps. Segment directions
... | true |
1e9d15bcc381cea35ba1496e94a25c4ed981878f | krzysztof-laba/Python_Projects_Home | /CodeCademy/SchoppingCart.py | 970 | 4.15625 | 4 | class ShoppingCart(object):
"""Creates shopping cart objects for users of our fine website"""
items_in_cart = {}
def __init__(self, customer_name):
self.customer_name = customer_name
print("Customer name:", self.customer_name)
def add_item(self, product, price):
"""Add product to the cart"""
if not product... | true |
05aa5bd36eba8a10f25800c4d61829f1e5710a67 | RadioFreeZ/Python_October_2018 | /python_fundamentals/function_basic2.py | 1,655 | 4.34375 | 4 | #Countdown - Create a function that accepts a number as an input. Return a new array that counts down by one, from the number
# (as arrays 'zero'th element) down to 0 (as the last element). For example countDown(5) should return [5,4,3,2,1,0].
def countdown(num):
return [x for x in range(num, -1,-1)]
print(cou... | true |
9257ae7106cf111e01eae338b262a65947204458 | DishaCoder/Solved-coding-challenges- | /lngest_pall_str.py | 221 | 4.125 | 4 | inputString = input("Enter string : ")
reverse = "".join(reversed(inputString))
size = len(inputString)
if (inputString == reverse):
print("Longest pallindromic string is ", inputString)
else:
for
| true |
eb31fc6b5c6b5957bf62c9a7c48864dee92aeba5 | lyvd/learnpython | /doublelinkedlist.py | 1,521 | 4.5 | 4 | #!/usr/bin/python
'''
Doubly Linked List is a variation of Linked list in which navigation is possible
in both ways either forward and backward easily as compared to Single Linked List.
'''
# A node class
class Node(object):
# Constructor
def __init__(self, data, prev, nextnode):
# object data
self.data = dat... | true |
df9f7a91df1bbb03d9f9661ece0c905936aba7b8 | lyvd/learnpython | /node.py | 552 | 4.1875 | 4 | #!/usr/bin/python
# Create a class which presents a node
class BinaryTree:
def __init__(self, rootObj):
# root node
self.key = rootObj
# left node
self.leftChild = None
self.rightChild = None
# Insert a left node to a tree
def insertLeft(self, newNode):
# if there is no left node
if self.leftChild ... | true |
030139068d2f3eafd4e60f3e3bfabf374a174e30 | akjalbani/Test_Python | /Misc/Tuple/xycoordinates.py | 499 | 4.15625 | 4 | """ what are the Mouse Coordinates? """
## practical example to show tuples
## x,y cordinates stored as tuple, once created can not be changed.
## use python IDLE to test this code.
## 08/06/2020
import tkinter
def mouse_click(event):
# retrieve XY coords as a tuple
coords = root.winfo_pointerxy()
print(... | true |
e6d26f45c62d5a0b943c6c43e712fe04dc9307d1 | akjalbani/Test_Python | /Misc/Network/dictionary_examples.py | 2,039 | 4.5 | 4 | # let us have list like this
devices = ['router1', 'juniper', '12.2']
print(devices)
############### Another way to print values #########################
for device in devices:
print(device)
#If we build on this example and convert the list device to a dictionary, it would look like this:
devices = {'hostname': 'rou... | true |
29900772d1df82995e52988be2eba8303b1457fd | akjalbani/Test_Python | /Misc/Turtle_examples/shape2.py | 288 | 4.15625 | 4 | # Turtle graphics- turtle will draw angle from 0-360 (15 deg)
# tested in repl.it
# Type- collection and modified
import turtle
turtle = turtle.Turtle()
for angle in range(0, 360, 15):
turtle.setheading(angle)
turtle.forward(100)
turtle.write(angle)
turtle.backward(100)
| true |
255724b8bd84e1a0dbd793d35eec9d935fb480f5 | susankorgen/cygnet-software | /Python100DaysClass2021/py/CoffeeMachineOOP/coffee_maker.py | 2,064 | 4.15625 | 4 | # Instructor code.
# Except: Student refactored the self.resources structure and added get_resources.
class CoffeeMaker:
"""Models the machine that makes the coffee"""
def __init__(self):
self.resources = {
"water": {
"amount": 500,
"units": "ml",
... | true |
84541b7ceb0b56ad10f0fede67d7c32823d09814 | ianmanalo1026/Projects | /Biginners/Guess the number (Project1).py | 2,015 | 4.15625 | 4 | import random
class Game:
"""Player will guess the random Number"""
def __init__(self):
self.name = None
self.number = None
self.random_number = None
self.indicator = None
def generateNumber(self):
self.random_number = random.randint(1,5)
return se... | true |
488421439b7188696f4e4d7f33dcc682e1bb3ef9 | 120Davies/Intro-Python-I | /src/13_file_io.py | 1,074 | 4.375 | 4 | """
Python makes performing file I/O simple. Take a look
at how to read and write to files here:
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
"""
# Open up the "foo.txt" file (which already exists) for reading
# Print all the contents of the file, then close the file
# Note: pay close... | true |
845883db9a28eb311b552650748ce4037f0ccb21 | RocioPuente/KalAcademyPython | /HW3/Palindrome.py | 353 | 4.1875 | 4 | def reverse(number):
rev=0
while number > 0:
rev = (10*rev)+number%10
number//=10
return rev
#print(reverse (number))
def isPalindrome(number):
if number == reverse(number):
return ("The number is a Palindrome")
else:
return ("The number is not a Palindrome")
... | true |
427d378903744e1d5e6b11fffcd1833e4a4e1465 | fannifulmer/exam-basics | /oddavg/odd_avg.py | 520 | 4.15625 | 4 | # Create a function called `odd_average` that takes a list of numbers as parameter
# and returns the average value of the odd numbers in the list
# Create basic unit tests for it with at least 3 different test cases
def odd_average(numbers):
new_list = []
try:
for number in range(len(numbers)):
... | true |
c9314fef90c6104045e9fc0ddb376f8b70304c5d | nipunramk/Introduction-to-Computer-Science-Course | /Video19Code/video19.py | 1,490 | 4.1875 | 4 | def create_board(n, m):
"""Creates a two dimensional
n (rows) x m (columns) board filled with zeros
4 x 5 board
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
3 x 2 board
0 0
0 0
0 0
>>> create_board(4, 5)
[[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
>>> create_board(3, 2)
[[0, 0],... | true |
4d1423ccc90971c23c833e73bbdc3374da797e0d | hannahpaxton/calculator-2 | /arithmetic.py | 2,463 | 4.1875 | 4 | """Functions for common math operations."""
def add(num1, num2):
"""Return the sum of the two inputs."""
# define a variable "sum"
# set this variable as the sum of num1, num2. sum = num1+num2
# return sum
sum_nums = num1 + num2
return sum_nums
def subtract(num1, num2):
"""Return the sec... | true |
b072e29a8a8f7ef5256c727290fe2a5c9fb949f5 | ArpitaDas2607/MyFirst | /exp25.py | 2,222 | 4.3125 | 4 | def break_words(stuff):
'''This function will, break up words for us.'''
words = stuff.split(' ')
return words
#Trial 1:
#print words
stuff = "Now this looks weird, it\'s blue and green and all in between"
statements = break_words(stuff)
print statements
#---------------------------------------------------... | true |
771482ef77c84b1daf7d50d8fce7d4d0aabf94ce | Anthima/Hack-CP-DSA | /Leetcode/BinarySearch/solution.py | 877 | 4.125 | 4 | # RECURSIVE BINARY SEARCH.
class Solution:
def binarySearch(self,arr,start,end,target):
if(start <= end):
# FINDING THE MIDDLE ELEMENT.
mid = start+((end-start)//2)
# CHECKING WHETHER THE MIDDLE ELEMENT IS EQUAL TO THE TARGET.
if(arr[mid] == targ... | true |
9687ded4776870f4a119959b99ef6bb5dda412ba | Anthima/Hack-CP-DSA | /Leetcode/Valid Mountain Array/solution.py | 596 | 4.3125 | 4 | def validMountainArray(arr):
i = 0
# to check whether values of array are in increasing order
while i < len(arr) and i+1 < len(arr) and arr[i] < arr[i+1]:
i += 1
# i == 0 means there's no increasing sequence
# i+1 >= len(arr) means the whole array is in increasing order
if i == 0 or i ... | true |
1eb14c2eb2e8174f6e5e759daaa32afba5bc9612 | rowand7906/cti110 | /M3HW1_AgeClassifier_DanteRowan.py | 421 | 4.34375 | 4 | #Age Classifier
#June 14, 2017
#CTI 110 M3HW1 - Age Classifier
#Dante' Rowan
# Get the age of the person
age = int(input('Enter the age of the person: '))
# Calculate the age of the person.
# Determine what age the person is
if 1:
print('Person is an infant.')
elif 1 > 13:
print('Person is a ch... | true |
2da8a1ca5b0ee01c712e682cdeef21c8b5f836bf | diesears/E01a-Control-Structues | /main10.py | 2,414 | 4.3125 | 4 | #!/usr/bin/env python3
import sys, utils, random # import the modules we will need
utils.check_version((3,7)) # make sure we are running at least Python 3.7
utils.clear() # clear the screen
print('Greetings!') #making the greetings text appear
colors = ['red','orange','yello... | true |
a4933426e475c8d8d34bc7ea7ca00f9706836202 | stanwar-bhupendra/LetsLearnGit | /snum.py | 411 | 4.1875 | 4 | #python program to find smallest number among three numbers
#taking input from user
num1 = int(input("Enter 1st number: "))
num2 = int(input("Enter 2nd number: "))
num3 = int(input("Enter 3rd number: "))
if(num1 <= num2) and (num1 <= num3):
snum = num1
elif(num2 <=num1) and (num2 <=num3):
snum = num2
else:
... | true |
773b41d9f6a9ad8133fda4c9954c35ca45dece2d | patrickbeeson/python-classes | /python_3/homework/Data_as_structured_objects/src/coconuts.py | 1,034 | 4.15625 | 4 | """
API for coconut tracking
"""
class Coconut(object):
"""
A coconut object
"""
def __init__(self, coconut_type, coconut_weight):
"""
Coconuts have type and weight attributes
"""
self.coconut_type = coconut_type
self.coconut_weight = coconut... | true |
30cfd0f856263b7889e535e9bea19fd645616ef9 | patrickbeeson/python-classes | /python_1/homework/secret_code.py | 870 | 4.59375 | 5 | #!/usr/local/bin/python3
"""
This program takes user input, and encodes it using the following cipher:
Each character of the string becomes the character whose ordinal value is 1 higher.
Then, the output of the program will be the reverse of the contructed string.
"""
# Get the user input as a string
user_input = str(... | true |
81de86c9e5ae59d686bb8155ea4a75fd8c26e84e | dinodre1342/CP1404_Practicals | /Prac5/week5_demo3.py | 802 | 4.28125 | 4 | def subject(subject_code, subject_name):
"""
This is a function for printing subject code and name.
:param subject_code: This is the JCU unique code for each subject
:param subject_name: This is the associated name matching the code
:return: A string message displaying both code and name
"""
... | true |
91b5a6c3d5e2e6e9efea43f259386b8633ced137 | tomasztuleja/exercises | /practisepythonorg/ex2_1.py | 324 | 4.1875 | 4 | #!/usr/bin/env python
# http://www.practicepython.org/exercise/2014/02/05/02-odd-or-even.html
inp = int(input("Type an Integer: "))
test = inp % 2
testfour = inp % 4
if test == 0:
print("It's an even number!")
if testfour == 0:
print("It's also a multiple of 4!")
else:
print("It's an odd number... | true |
3ce1a459cb6ffcbc9630c5944134b68c71c2d4ba | Manjunath823/Assessment_challenge | /Challenge_3/nested_dictionary.py | 844 | 4.34375 | 4 | def nested_key(object_dict, field):
"""
Input can be nested dict and a key, the function will return
value for that key
"""
keys_found = []
for key, value in object_dict.items():
if key == field:
keys_found.append(value)
elif isinstance(value, dict):
#t... | true |
1480e4f71cc8b0bc2b27f113937ba4b1cafe8cfb | saif93/simulatedAnnealingPython | /LocalSearch.py | 2,948 | 4.125 | 4 | """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
implementation of Simulated Annealing in Python
Date: Oct 22, 2016 7:31:55 PM
Programmed By: Muhammad Saif ul islam
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
import math
import random
from copy import deepcopy
... | true |
31d9dc0b6c3e23b9c7dbee6a63139df021b69b27 | SarwarSaif/Python-Problems | /Hackerank-Problems/Calendar Module.py | 842 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Oct 2 14:20:23 2018
@author: majaa
"""
import calendar
if __name__ == '__main__':
user_input = input().split()
m = int(user_input[0])
d = int(user_input[1])
y = int(user_input[2])
print(list(calendar.day_name)[calendar.weekday(y, m, d)].upper())
... | true |
0dfcd53fb2f4d82b58ce43b5726c6d682b61dc95 | SarwarSaif/Python-Problems | /Hackerank-Problems/NestedList.py | 1,897 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Sep 29 12:30:26 2018
@author: majaa
"""
if __name__ == '__main__':
marksheet=[]
"""
for _ in range(int(input())):
marksheet.append([input(),float(input())])
"""
n = int(input())
marksheet = [[input(), float(input())] for _ in ra... | true |
afb1f832a96caef7312c407477962a7b7ccbd0e5 | kubawyczesany/python | /case_swapping.py | 253 | 4.375 | 4 | # Given a string, simple swap the case for each of the letters.
# e.g. HeLLo -> hEllO
string = input ("Give a string to swap: ")
def swap(string_):
_string = ''.join([i.upper() if i.islower() else i.lower() for i in string_])
return (_string)
| true |
dc31d568218f5f710d20afc46f9b876c0e09c8a9 | lsaggu/introduction_to_python | /programs/programs.py | 1,874 | 4.28125 | 4 | #! /usr/bin/python
import sys
'''
her is the task i like you to do to reinforce the learning experience once you
are done with the tutorial.
a) write a program that uses loops over both x and y coordinates while x is in
1,2,3,4,5 and y is in 5,4,3,2,1 and prints the x and y coordinate
b) write a program that sums u... | true |
e689091397f37f3b4b166d1510e3dac045b8f799 | AbdulMoizChishti/python-practice | /Pfundamental Lab/Lab 7/task 2.py | 269 | 4.25 | 4 | def max(a, b, c):
if a>b and a>c:
print(a)
elif b>c and b>a:
print(b)
else:
print(c)
a=int(input("first number="))
b=int(input("second number="))
c=int(input("third number="))
max(a, b, c)
print("is the maximum of three integers") | true |
461ad5fff551ecfbb109842b78c03a33c3fe6156 | akshaali/Competitive-Programming- | /Hackerrank/minimumDistances.py | 1,525 | 4.375 | 4 | """
We define the distance between two array values as the number of indices between the two values. Given , find the minimum distance between any pair of equal elements in the array. If no such value exists, print .
For example, if , there are two matching pairs of values: . The indices of the 's are and , so their ... | true |
34240c8a1cd3c2132e6bd8121ae449b44ec92c58 | akshaali/Competitive-Programming- | /Hackerrank/TimeConversion.py | 1,432 | 4.1875 | 4 | """
Given a time in -hour AM/PM format, convert it to military (24-hour) time.
Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock.
Function Description
Complete the timeConversion function in the editor below. It sh... | true |
689a7f8c2643819de8930cfc93ceab46697b605a | akshaali/Competitive-Programming- | /Hackerrank/pickingNumbers.py | 2,479 | 4.5625 | 5 | """
Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less than or equal to . For example, if your array is , you can create two subarrays meeting the criterion: and . The maximum length su... | true |
c9488b2c6856e3c6b87db68ee117bb4e01380325 | akshaali/Competitive-Programming- | /Hackerrank/designerPDFViewer.py | 2,008 | 4.21875 | 4 | """
When you select a contiguous block of text in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, each word is highlighted independently. For example:
PDF-highighting.png
In this challenge, you will be given a list of letter heights in the alphabet and a string. Using the letter ... | true |
0e016e34e46435270dc0bba650016e7ba56a2ced | akshaali/Competitive-Programming- | /Hackerrank/gridChallenge.py | 2,281 | 4.15625 | 4 | """
Given a square grid of characters in the range ascii[a-z], rearrange elements of each row alphabetically, ascending. Determine if the columns are also in ascending alphabetical order, top to bottom. Return YES if they are or NO if they are not.
For example, given:
a b c
a d e
e f g
The rows are already in alphabe... | true |
918519d14aa6d0984c66c9bd431c51d9ac82c263 | akshaali/Competitive-Programming- | /Hackerrank/anagram.py | 2,668 | 4.4375 | 4 | """
Two words are anagrams of one another if their letters can be rearranged to form the other word.
In this challenge, you will be given a string. You must split it into two contiguous substrings, then determine the minimum number of characters to change to make the two substrings into anagrams of one another.
For e... | true |
54c0a48e87f31af1f129a16230921cce367a1dbc | akshaali/Competitive-Programming- | /Hackerrank/AppendandDelete.py | 2,682 | 4.125 | 4 | """
You have a string of lowercase English alphabetic letters. You can perform two types of operations on the string:
Append a lowercase English alphabetic letter to the end of the string.
Delete the last character in the string. Performing this operation on an empty string results in an empty string.
Given an integer... | true |
83e4ae0872601c41974ea40725d6dace62e0d338 | ariv14/python | /Day3_if_else/ifelse.py | 328 | 4.4375 | 4 | # Even or odd number finder
print("Welcome!! Please input any number to check odd or even !!\n")
# Get the input number as integer
number = int(input("Which number do you want to check? "))
#Write your code below this line
if number % 2 == 0:
print("The number is even number")
else:
print("The number is odd n... | true |
5b05abfb21bf9b8dea2dd9de4d1d859b09dc0dd5 | selinoztuurk/koc_python | /inclass/day1Syntax/lab1.py | 1,416 | 4.25 | 4 | def binarify(num):
"""convert positive integer to base 2"""
if num<=0: return '0'
digits = []
division = num
while (division >= 2):
remainder = division % 2
division = division // 2
digits.insert(0, str(remainder))
digits.insert(0, str(division % 2))
return ''.join(digits)
print(binarify(10)... | true |
c08f06f789fc81a1672e797a41c1d8cc39801864 | ptrkptz/udemy_python | /Python_Course/17_conditionals.py | 841 | 4.125 | 4 | grade1 = float(input ("Type the grade of the first test: "))
grade2 = float(input ("Type the grade of the second test: "))
absenses = int(input ("Type the number of absenses: "))
total_classes = int(input("Type the total number of classes: "))
avg_grade = (grade1 + grade2) /2
attendance = (total_classes - absenses) / ... | true |
1055f864fb549ae4202482553b16be2c046ff3d6 | ptrkptz/udemy_python | /Python_Course/15_booleans.py | 249 | 4.125 | 4 | num1 = float(input("Type the 1st num:"))
num2 = float(input("Type the 2nd num:"))
if (num1 > num2):
print(num1, " is greater than ", num2)
elif(num1==num2):
print(num1, " is equal to ", num2)
else:
print(num1, " is less than ", num2)
| true |
504b12b8de997337e4c6166ded242ff6d93d14ce | nimus0108/python-projects | /Tri1/anal_scores.py | 535 | 4.25 | 4 | # Su Min Kim
# Analysis Scores
num = input("")
num_list = num.split()
greater = 0
less = 0
def get_mean (num_list):
m = 0
i = 0
x = len(num_list)
for i in range (0, x):
number = int(num_list[i])
m += number
mean = m/x
return mean
for num in num_list:
number = int(num)
... | true |
c876053f4a23e86dcda291995c5142396ae5709f | meanJustin/Algos | /Demos/MergeSort.py | 1,451 | 4.15625 | 4 | # Python program for implementation of Selection
# Sort
import sys
import time
def mergeSort(arr):
if len(arr) >1:
mid = len(arr)//2 # Finding the mid of the array
L = arr[:mid] # Dividing the array elements
R = arr[mid:] # into 2 halves
mergeSort(L) # Sorting the first ... | true |
181accc46b0d03467a765e1b6f1fe8949f2799dc | prathapSEDT/pythonnov | /Collections/List/Slicing.py | 481 | 4.1875 | 4 | myList=['a',4,7,2,9,3]
'''
slicing is the concept of cropping sequence of elements
to crop the sequence of elements we need to specify the range in [ ]
synatx: [starting position: length]
here length is optinal, if we wont specify it, the compiler will crop the whole sequence
form the starting position
'''
# from inde... | true |
8c94185a47805431f457cb157523350c318ba831 | prathapSEDT/pythonnov | /Collections/List/Len.py | 208 | 4.1875 | 4 | '''
This length method is used to get the total length of elements that are available in the given list
'''
myList=['raj','mohan','krish','ram']
''' get the toatal length of a given list'''
print(len(myList)) | true |
3aee5a7a4a62a9ab4339ff518c5efaa5e0afa539 | prathapSEDT/pythonnov | /looping statements/WhileLoop.py | 244 | 4.1875 | 4 | '''
while loop is called as indefinite loop
like for loop , while loop will not end by its own
in the while we need write a condition to break the loop
'''
''' Print Numbers from 1-50 using while loop '''
i=1
while(i<=50):
print(i)
i+=1 | true |
9266236293a7e1c49900110e7e408876fcddf99d | VectorSigmaGen1/Basic_Introductory_Python | /Practical 10 - 3rd October 2019/p10p1.py | 1,261 | 4.28125 | 4 | # program to calculate the positive integer square root of a series of entered positive integer
"""
PSEUDOCODE
request input for a positive integer and assign to variable num
print "Please enter the positive integer you wish to calculate the square root of
(Enter a negative integer to exit program): "
... | true |
13080a3947d52e11797bd399fe8e3e3342dc4091 | VectorSigmaGen1/Basic_Introductory_Python | /Practical 13 - 10th October/p13p5.py | 1,013 | 4.53125 | 5 | # Program to illustrate scoping in Python
# Added extra variables and operations
"""
Pseudocode
DEFINE function 'f' of variable 'x' and variable 'y'
PRINT "In function f:"
Set x = x+1
Set y = y * 2
set z = x-1
PRINT "x is", 'x'
PRINT "y is", 'y'
PRINT "z is", 'z'
RETU... | true |
7d1038aaa9fe2af8374685ac523187026e58280a | VectorSigmaGen1/Basic_Introductory_Python | /Practical 09 - 3rd October 2019/p9p3.py | 969 | 4.28125 | 4 | # program to calculate the factorial of an entered integer
"""
Pseudocode
Set num = 0
WHILE input >= 0;
Request input
Print "Please enter a positive integer (If you wish to terminate the program, please enter a negative integer): "
run = 1
for i in range(1, input+1, 1)
run = run * i... | true |
0f1ad4d9a1bb6273f8e442b39f5c3281b4bd7e1a | VectorSigmaGen1/Basic_Introductory_Python | /Practical 07 - 26th Sep 2019/p7p3.py | 619 | 4.34375 | 4 | # program to print the first 50 integers and their squares
# for this program, I've used the first 50 positive integers starting with 0 and ending with 49
'''
print 'This is a program to print the integers 0 to 49 and their squares'
set variable=int(0)
While variable <50
print variable
print variab... | true |
7a63238e5cb6c4ea552dfa07a6c3f7470c452dfa | VectorSigmaGen1/Basic_Introductory_Python | /Practical 12 - 8th October 2019/p12p2.py | 1,703 | 4.40625 | 4 | # Define the function fibonacci which displays 'a' number of terms of the Fibonacci Sequence
# Program to check if an entered integer is a positive integer and if so to apply the function factorial to produce an answer
"""
Pseudocode
Define function 'fibonacci' of a variable 'a':
IF a > 0
set vari... | true |
6f859d260c8d4fd41bb03d315defb665e4bc20f2 | VectorSigmaGen1/Basic_Introductory_Python | /Practical 11 - 3rd October 2019/p11p3.py | 1,772 | 4.5 | 4 | # Program to check if an entered integer is a positive integer and if so to display that number of terms from the Fibonacci Sequence
"""
Pseudocode
request the input of an integer and assign it to variable 'length'
print "Please enter the number of terms in the Fibonacci Sequence you would like: "
WHILE leng... | true |
7fb84f004a36f1ca3e2b6dee6c5c91652c8b46ef | VectorSigmaGen1/Basic_Introductory_Python | /Practical 07 - 26th Sep 2019/p7p4.py | 746 | 4.28125 | 4 | # program to add the first 5000 integers and give an answer
# for this program, I've used the first 5000 positive integers,
# starting with 0 and ending with 4999.
"""
print 'This is a program to add the integers 0 to 4999 and give a total'
set variable=int(0)
set sum=int(0)
While variable <5000
set s... | true |
db540b0084bd73a4f11a39cdadc04c394ad4e7cb | VectorSigmaGen1/Basic_Introductory_Python | /Practical 18 - 17th October 2019/p18p1.py | 1,328 | 4.34375 | 4 | # an iterative version of the isPal function
# Checks whether a supplied string is a palindrome
"""
Pseudocode
DEFINE function 'isPal(s)'
Get the length of 's' and assign it to variable 'length'
IF 'length' <=1
RETURN TRUE
ELSE
set variable 'check' = 0
FOR 'i' in rang... | true |
6416bbd289069b4ad2208b0db6efe9e78c2cd05b | LuckyTyagi279/Misc | /python/loops_if.py | 481 | 4.1875 | 4 | #!/usr/bin/python
# Loops
# While Loop
while 0 :
Var=0
while Var < 5 :
Var = Var + 1
print Var
print "This is not in the loop!"
# Conditional Statement
# If statement
while 0 :
Var=1
if Var == 2 :
print "Condition is TRUE!"
else :
print "Condition is FALSE!"
while 0 :
Var = 0
while Var <= 100 :
if... | true |
0adc8e05c38e52d54f8667a0fc8e4a99337941ed | traines3812/traines3812.github.io | /range_demo.py | 605 | 4.5625 | 5 | # The range function generates a sequence of integers
a_range = range(5)
print('a_range ->', a_range)
print('list(a_range) ->', list(a_range))
# It is often used to execute a "for"loop a number of times
for i in range (5):
print(i, end= ' ') # executed five times
print()
# It is similar to the slice functio... | true |
7fea623eb32b3b2fbb1b8ef06f61ff42a4f5aeeb | HumayraFerdous/Coursera_Python_Basics | /Week4.py | 1,728 | 4.125 | 4 | #Methods
mylist=[]
mylist.append(5)
mylist.append(27)
mylist.append(3)
mylist.append(12)
print(mylist)
mylist.insert(1,12)
print(mylist)
print(mylist.count(12))
print(mylist.index(3))
print(mylist.count(5))
mylist.reverse()
print(mylist)
mylist.sort()
print(mylist)
mylist.remove(5)
print(mylist)
lastitem=mylist.p... | true |
96bf134d00802ad032852d9f789349fc358b042f | Jennykuma/coding-problems | /codewars/Python/invert.py | 368 | 4.15625 | 4 | '''
Invert Values
Level: 8 kyu
Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives.
invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5]
invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5]
invert([]) == []
You can assume that all values are integers.
'''
def invert(... | true |
b36a9a9b65550021d6a95067e28fadf68555ec67 | nishantgautamIT/python_core_practice | /pythonbasics/SetInPython.py | 1,273 | 4.125 | 4 | # Set in python
# method in set
# 1.union()
set1, set2, set3 = {1, 2, 3}, {3, 4, 5}, {5, 6, 7}
set_UN = set1.union(set2, set3)
print(set1)
print(set_UN)
# 2. intersection()
set_int = set2.intersection(set1)
print(set_int)
# 3. difference()
set_diff = set1.difference(set2)
print(set_diff)
# 4. symmetric_difference()
... | true |
a250d32dc61ec7b738b96e5e911c09434cc6f25f | nvincenthill/python_toy_problems | /string_ends_with.py | 417 | 4.25 | 4 | # Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
# Examples:
# string_ends_with('abc', 'bc') # returns true
# string_ends_with('abc', 'd') # returns false
def string_ends_with(string, ending):
length = len(ending)
sliced = st... | true |
c5167aaf0b17bc6b744043c389924270e3e235fe | nguyenlien1999/fundamental | /Session05/homework/exercise3.py | 408 | 4.625 | 5 | # 3 Write a Python function that draws a square, named draw_square, takes 2 arguments: length and color,
# where length is the length of its side and color is the color of its bound (line color)
import turtle
def draw_square(size,colors):
f = turtle.Pen()
f.color(colors)
# f.color(color)
for i in range(3):
... | true |
3c927b72492f4f9a438ed8711aaff757b0f56009 | Elijah-M/Module10 | /class_definitions/invoice.py | 2,468 | 4.40625 | 4 | """
Author: Elijah Morishita
elmorishita@dmacc.edu
10/26/2020
This program is used for creating an example of the uses of a class
"""
class Invoice:
"""
A constructor that sets the variables
"""
def __init__(self, invoice_id, customer_id, last_name, first_name, phone_number, address, items_with_price=... | true |
60769c7f9ecb97369f20e2fcbdb9ba9fd8c70b85 | jasanjot14/Data-Structures-and-Algorithms | /Algorithms/iterative_binary_search.py | 1,661 | 4.375 | 4 | # Function to determine if a target (target) exists in a SORTED list (list) using an iterative binary search algorithm
def iterative_binary_search(list, target):
# Determines the search space
first = 0
last = len(list) - 1
# Loops through the search space
while first <= last:
# ... | true |
06bf16ed3dc113f6c43578271d1e63088317cfbc | ajit-jadhav/CorePython | /1_Basics/7_ArraysInPython/a1_ArrayBasics.py | 2,409 | 4.40625 | 4 | '''
Created on 14-Jul-2019
@author: ajitj
'''
## Program 1
## Creating an integer type array
import array
a = array.array('i',[5,6,7])
print('The array elements are: ')
for element in a:
print (element)
## Program 2
## Creating an integer type array v2
from array import *
a = arr... | true |
fac0907fa4db80c8d9aa200e6f2f25d260e7e3d0 | alex-gagnon/island_of_miscripts | /pyisland/src/classic_problems/StringToInteger.py | 1,677 | 4.15625 | 4 |
import re
class Solution:
"""Convert a string to an integer.
Whitespace characters should be removed until first non-whitespace character
is found.
Next, and optional plus or minus sign may be found which should then be followed
by any number of numerical digits.
The digits should... | true |
d42c35cf40853e6e1b60742c5c8aadf0a840d573 | returnzero1-0/logical-programming | /sp-7.py | 315 | 4.21875 | 4 | # Python Program to Read Two Numbers and Print Their Quotient and Remainder
'''
Quotient by floor division //
Remainder by mod %
'''
num1=int(input("Enter number 1 :"))
num2=int(input("Enter number 2 :"))
quotient=num1//num2
remainder=num1%num2
print("Quotient is :",quotient)
print("Remainder is :",remainder)
| true |
533516eaf7b44a007b79a9f00e283bfd865ad017 | friedaim/ITSE1359 | /PSET4/PGM1.py | 1,934 | 4.125 | 4 | # Program to calculate loan interest,
# monthly payment, and overall loan payment.
def calcLoan(yrRate,term,amt):
monthRate = yrRate/12
paymentNum = (pow(1+monthRate,term)*monthRate)
paymentDen = (pow(1+monthRate,term)-1)
payment = (paymentNum/paymentDen)*amt
paybackAmt = payment*term
totalInte... | true |
532eb7059007dab0ce39b0e7a53559d12c696d86 | mjadair/intro-to-python | /functions/arguments.py | 1,473 | 4.375 | 4 | # Navigate to functions folder and type python arguments.py to run
# * 🦉 Practice
# ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/"
# ? Define a function "sayHello" that accepts a "name" parameter. It should return a string of 'Hello (the name)!'
# ? Call and print the result ... | true |
485f7f408cbe0ba4f7ed22f940dfe1da28fc18b4 | mjadair/intro-to-python | /control-flow/loops.py | 1,190 | 4.1875 | 4 | # * ----- FOR LOOPS ------ *
# ! Navigate to the directory and type `python loops.py` to run the file
# * 🦉 Practice
# ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/"
# ? Write a for loop that prints the numbers 0 - 10
# ? Write a for loop that prints the string 'Hello W... | true |
afca7c31b72f51f3cf3b96c33dcf0e9da76a4f39 | Zahidsqldba07/Python_Practice_Programs | /college/s3p4.py | 235 | 4.1875 | 4 | # WAP to find largest and smallest value in a list or sequence
nums = []
n = int(input("How many numbers you want to input? "))
for i in range(n):
nums.append(int(input(">")))
print("Max: %d\nMin: %d" % (max(nums), min(nums)))
| true |
1d91eda9d5e992d2ba82dd74cec9586b5d0c58b4 | Zahidsqldba07/Python_Practice_Programs | /college/p7.py | 279 | 4.375 | 4 | # WAP to read a set of numbers in an array & to find the largest of them
def largest(arr):
return max(arr)
arr = list()
num = input("How many elements you want to store? ")
for i in range(int(num)):
num = input("Num: ")
arr.append(int(num))
print(largest(arr))
| true |
6c39bdf7ab868326265d9724569004623651d493 | Zahidsqldba07/Python_Practice_Programs | /college/s2p7.py | 269 | 4.125 | 4 | # WAP that demonstrates the use break and continue statements to alter the flow of the loop.
while True:
name = str(input("Name: "))
if name.isalpha():
print("Hello %s" % name)
break
else:
print("Invalid name.\n")
continue
| true |
b2cece558ed3391220af52e1e13b2329bca82ab3 | Zahidsqldba07/Python_Practice_Programs | /college/s8p2.py | 358 | 4.1875 | 4 | # Define a class name circle which can be constructed using a parameter radius.
# The class has a method which can compute the area using area method.
class Circle:
radius = 0
def __init__(self, radius):
self.radius = radius
def displayArea(self):
print("Area:", (3.14 * (self.radius ** 2... | true |
6a77a5bca7b96861c6bbd9404ebc467afd28d470 | kokilavemula/python-code | /inheritances.py | 922 | 4.25 | 4 | #Create a Parent Class
class Person:
def __init__(self, fname, lname):
self.firstname = fname
self.lastname = lname
def printname(self):
print(self.firstname, self.lastname)
#Use the Person class to create an object, and then execute the printname method:
x = Person("kokila", "vemula")
x.printname()... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.