blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
cf4a064e95f153869ea27f689877f86dbbcd1888 | ethan786/hacktoberfest2021-1 | /Python/ReplaceDuplicateOccurance.py | 808 | 4.15625 | 4 | # Python3 code to demonstrate working of
# Replace duplicate Occurrence in String
# Using split() + enumerate() + loop
# initializing string
test_str = 'Gfg is best . Gfg also has Classes now. \
Classes help understand better . '
# printing original string
print("The original string is : " + str(... | true |
412aa8efb5779739eed62eca2bf84d46dbd5da52 | ethan786/hacktoberfest2021-1 | /Python/VerticalConcatination.py | 626 | 4.21875 | 4 | #Python3 code to demonstrate working of
# Vertical Concatenation in Matrix
# Using loop
# initializing lists
test_list = [["Gfg", "good"], ["is", "for"], ["Best"]]
# printing original list
print("The original list : " + str(test_list))
# using loop for iteration
res = []
N = 0
while N != len(test_list):
... | true |
98db41c342b502dadb0c1a41470f07b48a1557eb | qianjing2020/cs-module-project-hash-tables | /applications/crack_caesar/crack_caesar.py | 1,216 | 4.15625 | 4 | # Use frequency analysis to find the key to ciphertext.txt, and then
# decode it.
# Your code here
special = ' " : ; , . - + = / \ | [] {} () * ^ & '
def alphabet_frequency(filename):
#obtain text from txt file
f = open(filename, 'r')
s = f.read()
f.close
# list contains list of alphabets
lst ... | true |
2b56d5789f94816a770ea759a6e3d5b336a70aba | luizfboss/MapRender | /main.py | 1,076 | 4.1875 | 4 | import folium
# A little help: add this code to a folder to open the map after running the code
a = float(input('x coordinate: ')) # Asks for the x coordinate
b = float(input('y coordinate: ')) # Asks for the y coordinate
city = str(input("Place's name: ")) # Asks for the city's name
# The city name won't change any... | true |
b806b42c533faa0c2cde79d4d067b53fb70abbcc | marcmatias/challenges-and-studies | /Edabit/python/Moving to the End.py | 420 | 4.3125 | 4 | '''
Flip the Boolean
Create a function that reverses a boolean value and returns the
string "boolean expected" if another variable type is given.
Examples
reverse(True) ➞ False
reverse(False) ➞ True
reverse(0) ➞ "boolean expected"
'''
def reverse(... | true |
4abd2567d26205e70109e9d2358c9869809850f3 | marcmatias/challenges-and-studies | /Edabit/python/Return the Factorial.py | 378 | 4.28125 | 4 | '''
Return the Factorial
Create a function that takes an integer and returns the factorial of that integer.
That is, the integer multiplied by all positive lower integers.
Examples
factorial(3) ➞ 6
factorial(5) ➞ 120
factorial(13) ➞ 6227020800
'''
def factorial(num):
... | true |
40f5bd514abcfb94d581ce838eebed35c176d427 | FarabiHossain/Python | /Python Program/5th program.py | 321 | 4.125 | 4 | #How to get input from the user
fname = input("Enter your first name: ")
lname = input("Enter your last name: ")
school = input("Enter your school name: ")
age = input("Enter your age: ")
name = fname +" "+ lname
print("my name is " +name)
print("my school name is "+school)
print("i am " ,age, "years old"... | true |
4c35c58813cfb2697a8e00c7497b05f290aea394 | anniequasar/session-summaries | /Red_Hat/sess_10/10a_modules.py | 1,303 | 4.375 | 4 | """
Modules - Beginners Python Session 10
Demonstrates how program can tell if it has been run as script or imported as module
@author: Tim Cummings
Every python program file is a module.
A module is a group of python functions, classes, and/or a program which can be used from other python programs.
The module nam... | true |
a5063e58428fc5053b8248c9c684378d67713bdc | heggy231/final_coding_challenges | /practice_problems/non_repeat_substring.py | 334 | 4.15625 | 4 | """
Given a string as input, return the longest substring which does not return repeating characters.
"""
def non_repeat_substring(word):
"""
>>> non_repeat_substring("abbbbc")
'ab'
"""
start = 0
iterator = 0
maximum_substring = ""
# iterate through the string
# have an end coun... | true |
55d4008280c22a62a031019d82ed0434c7ffdcec | sidkushwah123/pythonexamples | /calsi.py | 1,701 | 4.3125 | 4 | def calculator():
print("Hello! Sir, My name is Calculator.\nYou can follow the instructions to use me./n")
print("You can choose these different operations on me.")
print("Press 1 for addition(x+y)")
print("Press 2 for subtraction(x-y)")
print("Press 3 for multiplication(x*y)")
print("Press 4 f... | true |
8ee3f7247112e5afb3efdc0c41d303b1426fa216 | prophecyofagod/Python_Projects | /mario_saiz_Lab4c.py | 1,451 | 4.15625 | 4 | #Author: Mario Saiz
#Class: COSC 1336
#Program: Lab 4c
#Getting grades that are entered, determining the letter grade, and
#then calculating the class average by adding all the grades up, and
#dividing by the number of entered grades
print("\n"*25)
name = input("What is your name?: ")
grade = float(input("Ple... | true |
c123862957de1163da3601eb2a5ccfb1fb0073ec | Yi-Hua/HackerRank_practicing | /Python_HackerRank/BasicDataTypes/Lists.py | 1,567 | 4.375 | 4 | # Lists
''' Consider a list (list = []). You can perform the following commands:
1. insert i e: Insert integer e at position i.
2. print: Print the list.
3. remove e: Delete the first occurrence of integer e.
4. append e: Insert integer e at the end of the list.
5. sort: Sort the list.
... | true |
2b7d71339c21528b07b3af83ed06c15d013a2a01 | chrisdavidspicer/code-challenges | /is_prime.py | 617 | 4.1875 | 4 | # Define a function that takes one integer argument
# and returns logical value true or false depending on if the integer is a prime.
# Per Wikipedia, a prime number (or a prime) is
# a natural number greater than 1 that has no
# positive divisors other than 1 and itself.
def is_prime(num):
# print(range(num))
if... | true |
616186ec59d49fbf3b4437a1ddaf8a40a2ab816a | parth04/Data-Structures | /Trees/symmetricTree.py | 1,574 | 4.375 | 4 | """
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the following [1,2,2,null,3,null,3] is not:
1
/ \
2 2
\ \
3 3
"""
# Definition for a b... | true |
d8f3d005639d4bf74738072c79381721c929a3a3 | parth04/Data-Structures | /misc/rotateImage.py | 1,456 | 4.4375 | 4 | """
48. Rotate Image
Medium
You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).
You have to rotate the image in-place, which means you have to modify the input 2D matrix directly. DO NOT allocate another 2D matrix and do the rotation.
Example 1:
Input: matrix = [[... | true |
f1b39bf74c7844753d0a02832e73018cc344b11e | ZTcode/csc150Python | /convert3.py | 458 | 4.125 | 4 | # convert.py
# A program to convert Celsius to Fahreheit
def main():
print("Converting from celcius to fahrenheit")
celsius = eval(input("What is the Celsius Temperature? "))
fahrenheit = 9/5 * celsius + 32
if fahrenheit > 90:
print("It's hot as hell out!")
if fahrenheit < 30:
... | true |
f92cf43577af65a94f924d83123734bf7eafbd20 | pwang867/LeetCode-Solutions-Python | /0874. Walking Robot Simulation.py | 2,330 | 4.3125 | 4 | # cartesian coordinate
# time O(n), space O(1)
class Solution(object):
def robotSim(self, commands, obstacles):
"""
:type commands: List[int]
:type obstacles: List[List[int]]
:rtype: int
"""
dir = (0, 1) # current moving direction
pos = (0, 0)
obstac... | true |
902e5293b4ce676efe711da81d8015b9c383d4d1 | pwang867/LeetCode-Solutions-Python | /0225. Implement Stack using Queues.py | 2,197 | 4.5 | 4 | # rotate the queue whenever push a new node to stack
from collections import deque
class MyStack(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.queue = deque()
def push(self, x): # time O(n)
"""
Push elemen... | true |
fec96f7d0cd28d6151e7d100a72597a178e2e67d | pwang867/LeetCode-Solutions-Python | /0543. Diameter of Binary Tree.py | 1,790 | 4.125 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# time O(n), space O(depth)
# same as method 1, but use attributes
# diameter: count of edges, not count of nodes
class Solution(object):
def dia... | true |
7a5f58683cea86a8770142cf57c7b6fa2f420150 | eejay73/python-bootcamp | /ch20-lambdas-builtin-functions/main.py | 1,273 | 4.53125 | 5 | #!/usr/bin/env python3
"""
Chapter 20 - Lambdas and builtin functions
@author Ellery Penas
@version 2018.04.07
"""
import sys
def main():
"""main line function"""
# Normal function definetion
def square(x):
return x * x
# lambda version of the same function
# square2 = lambda num: num * n... | true |
185ae423da8786ee4454391f2de6c9c216cb9d92 | matthew-t-smith/Python-Archive | /Merge-Sort.py | 1,464 | 4.125 | 4 | ## Merge-sort on a deck of cards of only one suit, aces high
import math
## We will assign a number value to face cards so the computer can determine
## which is higher or lower
J = 11
Q = 12
K = 13
A = 14
## Here is our shuffled deck
D = [4, 9, Q, 3, 10, 7, J, 5, A, 6, K, 8, 2]
## We define the merge... | true |
b9e10a145429022614da4426e4d461b77cb12007 | Raolaksh/Python-programming | /If statement & comparision.py | 466 | 4.15625 | 4 |
def max_num(num1, num2, num3):
if num1 >= num2 and num1>= num3:
return num1
elif num2 >= num1 and num2 >= num3:
return num2
else:
return num3
print(max_num(300, 40, 5))
print("we can also compare strings or bulleans not only numbers")
print("these are comparision ope... | true |
a0788ac07a593928ed83bcaee802c3459538022f | miquelsi/intro-to-python-livelessons | /Problems/problem_6_lucky_number_guess.py | 446 | 4.21875 | 4 | """
Guess the number between 1 and 10
"""
import random
answer = random.randint(1, 10)
guess = int(input("I'm thinking of a number between 1 and 10: "))
# If the number is correct, tell the user
# Otherwise, tell them if the answer is higher or lower than their guess
if answer == guess:
print("It is correct!")
e... | true |
22b98de5c1195b2101bd649fed279cefbff98b67 | decadevs/use-cases-python-Kingsconsult | /static_methods.py | 899 | 4.21875 | 4 | # Document at least 3 use cases of static methods
# This method don't rely on the class attributes
# They are completely independent of everythin around them
# example 1
class Shape:
def __init__(self, name):
self.radius = name
@staticmethod
def calc_sum_of_angle(n):
return (2 * n... | true |
2dcf1f9b20227194ee543bf4d07fd10792fb9256 | RibRibble/python_june_2017 | /Rib/multiply2.py | 514 | 4.40625 | 4 | # Multiply:
# Create a function called 'multiply' that iterates through each value in a list (e.g. a = [2, 4, 10, 16])
# and returns a list where each value has been multiplied by 5. The function should multiply each value in the
# list by the second argument. For example, let's say:
# a = [2,4,10,16]
# Then:
# b ... | true |
7b575dc10ab4460b380d40c6971fedd097f9cecc | RibRibble/python_june_2017 | /Rib/ave2.py | 241 | 4.21875 | 4 | # Average List
# Create a program that prints the average of the values in the list: a = [1, 2, 5, 10, 255, 3]
print 'For the following list: '
a = [1, 2, 5, 10, 255, 3]
print a
print 'The average of the values in the list is: ' ,sum(a)/2
| true |
6d3c76402feb77a15890b728883722196df4094a | Amertz08/ProjectEuler | /Python/Problem005.py | 519 | 4.15625 | 4 | '''
Takes in a value, start point, and end point
returns true if value is evenly divisible from start to end
'''
def eDiv(value, start, end):
for a in range(start, end + 1):
if (value % a != 0): return False
return True
#Prompt input
print('''
Program will find smallest number than can be evenly divis... | true |
e8c3afdb41c2b9f095f29a42f07b43140f309ba1 | maggie-leung/python_exercise | /02 Odd Or Even.py | 401 | 4.21875 | 4 | num = int(input('Input the number you want to check'))
if (num % 4 == 0):
print('This is a multiple of 4')
elif (num % 2 == 0):
print('This is an even number')
else:
print('This is an odd number')
check = int(input('Check for the multiple'))
if (num % check == 0):
print(str(num) + ' is a multiple of '... | true |
e2e55c6c6561d91489e06f710835379e9cbc771e | cybersquare/G12_python_solved_questions | /files_exception/count_chars.py | 821 | 4.25 | 4 |
# Read a text file and display the number of vowels/ consonants/uppercase/ lowercase
# characters in the file.
file = open('hash.txt', "r")
vowels = set("AEIOUaeiou")
cons = set("bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ")
upper = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
lower = set('abcdefghijklmnopqrstuvwxyz')
text =... | true |
a6bb1b1effc36daa8021e53a0a05a64c49a0274e | mikaelaberg/CIS699 | /Ch2_Work/Ch2_4.py | 1,048 | 4.5625 | 5 | '''R-2.4 Write a Python class, Flower, that has three instance variables of type str,
int, and float, that respectively represent the name of the flower, its number
of petals, and its price. Your class must include a constructor method
that initializes each variable to an appropriate value, and your class should
includ... | true |
7a9ea799d19d80b1c22d070ac2588905bcd91dd2 | thomaslast/Test | /Python/Codeacademy/dice_game.py | 1,118 | 4.15625 | 4 | from random import randint
from time import sleep
"""
Program that rolls a pair of dice and asks the user to guess the sum.
"""
number_of_sides = 6
def check_guess(guess):
if guess > max_val:
print ("Guess is too high, guess again")
guess = get_user_guess()
elif guess <= 0:
print ("Guess must be Va... | true |
fe4c8c4e20eb92cacc4ae61803b7b2bda8b243f3 | mrpodkalicki/Numerical-Methods | /lab_1/tasks.py | 686 | 4.125 | 4 | #TASKS (4p)
#1 calculate & print the value of function y = 2x^2 + 2x + 2 for x=[56, 57, ... 100] (0.5p)
#2 ask the user for a number and print its factorial (1p)
#3 write a function which takes an array of numbers as an input and finds the lowest value. Return the index of that element and its value (1p)
#4 looking at ... | true |
6c8dfee1a9d82c98efb5ef9fd3379433bf68407f | LalithK90/LearningPython | /privious_learning_code/OS_Handling/os.readlink() Method.py | 708 | 4.15625 | 4 | # Description
#
# The method readlink() returns a string representing the path to which the symbolic link points. It may return an absolute or relative pathname.
# Syntax
#
# Following is the syntax for readlink() method −
#
# os.readlink(path)
#
# Parameters
#
# path − This is the path or symblic link for which we are... | true |
72f57e54a9390cb5b076ea4cc409da0e7759713d | LalithK90/LearningPython | /privious_learning_code/OS_Handling/os.popen() Method.py | 1,048 | 4.21875 | 4 | # Description
#
# The method popen() opens a pipe to or from command.The return value is an open file object connected to the pipe, which can be read or written depending on whether mode is 'r' (default) or 'w'.The bufsize argument has the same meaning as in open() function.
# Syntax
#
# Following is the syntax for pop... | true |
5a1a68b0a693a534361db3206bceab00e68106fc | LalithK90/LearningPython | /privious_learning_code/String/String rfind() Method.py | 808 | 4.375 | 4 | str1 = "this is really a string example....wow!!!"
str2 = "is"
print(str1.rfind(str2))
print(str1.rfind(str2, 0, 10))
print(str1.rfind(str2, 10, 0))
print(str1.find(str2))
print(str1.find(str2, 0, 10))
print(str1.find(str2, 10, 0))
# Description
#
# The method rfind() returns the last index where the substring str is... | true |
4a234927f0f6f3fb11abc4ae52f147ba59b197cb | LalithK90/LearningPython | /privious_learning_code/List/List extend() Method.py | 438 | 4.21875 | 4 |
# Description
#
# The method extend() appends the contents of seq to list.
# Syntax
#
# Following is the syntax for extend() method −
#
# list.extend(seq)
#
# Parameters
#
# seq − This is the list of elements
#
# Return Value
#
# This method does not return any value but add the content to existing list.
# Example
aLi... | true |
98d84207ce7c25952584fcbfabad329cc4690d40 | LalithK90/LearningPython | /privious_learning_code/List/List max() Method.py | 491 | 4.40625 | 4 |
# Description
#
# The method max returns the elements from the list with maximum value.
# Syntax
#
# Following is the syntax for max() method −
#
# max(list)
#
# Parameters
#
# list − This is a list from which max valued element to be returned.
#
# Return Value
#
# This method returns the elements from the list with m... | true |
14c1c4bdd5817b28b1b758d5b3d3fe51bb959f95 | LalithK90/LearningPython | /privious_learning_code/QuotationInPython.py | 448 | 4.40625 | 4 | print("Quotation in Python")
# Python accepts single ('), double (") and triple (''' or """) quotes to denote string literals,
# as long as the same type of quote starts and ends the string.
# The triple quotes are used to span the string across multiple lines.
word = 'word'
sentence = "This is a sentence."
paragraph... | true |
14c050442a17bf7f8ffd71aa476d582735789d7d | LalithK90/LearningPython | /privious_learning_code/String/String isupper() Method.py | 509 | 4.53125 | 5 | str = "THIS IS STRING EXAMPLE....WOW!!!"
print(str.isupper())
str = "THIS is string example....wow!!!"
print(str.isupper())
# Description
#
# The method isupper() checks whether all the case-based characters (letters) of the string are uppercase.
# Syntax
#
# Following is the syntax for isupper() method −
#
# str.isup... | true |
367c5c5015d27b792d9c1e905dff7a72992ad186 | LalithK90/LearningPython | /privious_learning_code/String/String lower() Method.py | 400 | 4.21875 | 4 | str = "THIS IS STRING EXAMPLE....WOW!!!"
print(str.lower())
# Description
#
# The method lower() returns a copy of the string in which all case-based characters have been lowercased.
# Syntax
#
# Following is the syntax for lower() method −
#
# str.lower()
#
# Parameters
#
# NA
#
# Return Value
#
# This method returns ... | true |
65329c697810fa82fb33abcfcdf3d452ca4da93f | LalithK90/LearningPython | /privious_learning_code/Dictionary/dictionary update() Method.py | 467 | 4.1875 | 4 | # Description
#
# The method update() adds dictionary dict2's key-values pairs in to dict. This function does not return anything.
# Syntax
#
# Following is the syntax for update() method −
#
# dict.update(dict2)
#
# Parameters
#
# dict2 − This is the dictionary to be added into dict.
#
# Return Value
#
# This method d... | true |
9ffc86036d180e3c720348674ba0a62fd1c7c23e | LalithK90/LearningPython | /privious_learning_code/String/StringCenter()Method.py | 394 | 4.21875 | 4 | str = "this is string example....wow!!!"
print("str.center(40, 'a') : ", str.center(40, 'a'))
# The method center() returns centered in a string of length width. Padding is done using the specified fillchar.
# Default filler is a space. Syntax
#
# str.center(width[, fillchar])
#
# Parameters
#
# width − This is the to... | true |
ca09433b3b42f4053288524ad61ad69f67d13659 | scivarolo/py-ex04-tuples | /zoo.py | 481 | 4.25 | 4 | # Create a tuple named zoo
zoo = ("Lizard", "Fox", "Mammoth")
# Find an animal's index
print(zoo.index("Fox"))
# Determine if an animal is in your tuple by using value in tuple
lizard_check = "Lizard" in zoo
print(lizard_check)
# Create a variable for each animal in the tuple
(lizard, fox, mammoth) = zoo
# Convert ... | true |
2c0da1b242caabe0009335f12095c5cec1779976 | AliCanAydogdu/Intro_to_Python | /chapter2_Lists.py | 2,565 | 4.53125 | 5 | #Here's a simple example of a list
bicycles = ['trek','canonndale','redline','specialized' ]
print(bicycles[0])
print(bicycles[0].title())
#Index Numbers Start at 0, Not 1
# At Index -1, python returns the last item, at index -2 second item from the end of list, so on.
#Using Individual Values from the list
bicycles... | true |
d5b41acd88de4996f061b79ef73ec60fa68ce747 | yami2021/PythonTests | /Assignment/area_traingle_new.py | 585 | 4.125 | 4 | def check_user_input(input):
try:
# Convert it into integer
val1 = float(input)
return val1
#return val1
#print("Input is an integer number. Number = ", val)
except ValueError:
print("No.. input is not a number. It's a string")
area()
def area():
i... | true |
6b000f4ecd08235fe57b54a58d7dbe8a7d5a530f | markplotlib/treehouse | /basic-python/Lists/list_intro.py | 2,201 | 4.1875 | 4 | # quiz of lists
dict_of_lists = {
'list("Paul")': list("Paul"),
'list(["Paul"])': list(["Paul"]),
'list(["Paul", "John"])': list(["Paul", "John"])
}
def quiz_of_lists(dict_of_lists):
for key, value in dict_of_lists.items():
print("=" * 44)
print("What is the length of this list? ")... | true |
685094695eacff77c8838ef8ba06c56b31819d95 | himrasmussen/solitaire-fyeah | /testsuite.py | 1,621 | 4.125 | 4 |
class Table():
"""A class modelling the table."""
def __init__(self, deck):
"""Initialize the rows and stacks."""
self.stack = Stack()
self.columns = {i: [] for i in range(7)} #?
self.acestacks = OrderedDict()
for suit in "hearts diamonds spades clubs".split():
... | true |
0e80cfb3ac5ea66678c4b99ad82e536098e09789 | darrenpaul/open-pipeline | /environment/modules/data/op_dictionary.py | 771 | 4.1875 | 4 | def merge_dictionaries(original=None, new=None):
"""
This will merge two dictionaries together, the original dictionary
will be updated in memory.
Keyword Arguments:
original {dictionary} -- The original dictionary
new {dictionary} -- The new dictionary
"""
for key, val in new.i... | true |
0c28a6e808b0ee6bf59d613d4c006b7914626eef | Pixelus/Programming-Problems-From-Programming-Books | /Python-crash-course/Chapter7/multiples_of_ten.py | 218 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Nov 29 2018
@author: PixelNew
"""
number = input("Enter a number please: ")
if(int(number) % 2 == 0):
print("Your number is even.")
else:
print("Your number is odd.")
| true |
c895b752f72217d3b4afe224554d861b6f09be75 | chaitanyamean/python-algo-problems | /Array/monotonic.py | 454 | 4.125 | 4 |
'''Given a non-empty array of integers, find if the array is monotonic or not
'''
def isMonotonic(array):
isNonIncreasing = True
isNonDecreasing = True
for i in range(1, len(array)):
if array[i] < array[i -1]:
isNonDecreasing = False
if array[i] > array[i-1]:
isNon... | true |
cd6d93b45427751279adf4560ebe1717562133f9 | AlexB196/python-exercises | /.idea/augmenteda_inaloop_challenge.py | 521 | 4.40625 | 4 | number = 10
multiplier = 8
answer = 0
# add your loop after this comment
for i in range(multiplier):
i = number
answer += i
#IMPORTANT! I don't have to use i above. I can simply type answer += number
#the loop will end when the condidition becomes false, but I dont have to use that i
print(answer)
#i... | true |
bd3e9521b7c49cfbbed1c9e2a62aefc31a827540 | AlexB196/python-exercises | /.idea/motorbike.py | 252 | 4.25 | 4 | bike = {"make": "Honda", "model": "250 dream", "color": "red", "engine_size": 250}
print(bike["engine_size"])
print(bike["color"])
#bike is a dictionary
#we can access different entry from the dictionary - doesn't matter if it's a number
#or a string | true |
c280890b699b21cedad4771f4fa22dff35292bc8 | alexnicholls1999/Python | /BMI.py | 252 | 4.1875 | 4 | #User Enters weight in Kilograms
print ("What is your weight? (kg)?")
weight = int(input())
#User Enters Height in Metres
print ("What is your height? (m)")
height = float(input())
#Users BMI
print ("Your bmi is","{0:.2f}".format(weight/height**2)) | true |
d6955c89a330de6c7627929e25be196741a7b298 | Deep455/Python-programs-ITW1 | /python_assignment_1/21.py | 289 | 4.15625 | 4 | def spliting(arr,n):
return [arr[i::n] for i in range(n)]
a=input("enter the elements of list seperated by commas : ").split(",")
arr=list(a)
n=int(input("enter size of splitted list u want to see :"))
print("list : ")
print(arr)
print("list after spliting : ")
print(spliting(arr,n))
| true |
ddd8cc2fe85fe0019c7bf9906542d47df1a68c18 | Deep455/Python-programs-ITW1 | /python_assignment_1/4.py | 242 | 4.1875 | 4 | def inserting(string,word):
l=len(string)
l=l//2
new_string=string[:l]+word+string[l:]
return new_string
string=input("enter a string : ")
word=input("enter a word u want to insert : ")
new_string=inserting(string,word)
print(new_string)
| true |
85cca267caf2f35474c4786c9b939d30dc4e4450 | shubham79mane/tusk | /reverse_link_list.py | 1,515 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Jul 5 09:50:42 2021
@author: mane7
"""
#!/bin/python3
import math
import os
import random
import re
import sys
class DoublyLinkedListNode:
def __init__(self, node_data):
self.data = node_data
self.next = None
self.prev = None
class DoublyLinke... | true |
cb6b0d3fe2cf81a12a4ca2caee1789b48975c6f5 | SophiaTanOfficial/John-Jacob | /speak.py | 2,137 | 4.25 | 4 | # Let's use some methods to manipulate the string stored in name.
name = "John Jacob Jingleheimer Schmidt"
# 1. Use print and a built-in method to print out the string "jOHN jACOB jINGLEHEIMER sCHMIDT"
print(name.swapcase())
# 2. Use print and a built-in method to print out the string "JOHN JACOB JINGELHEIMER SCHMI... | true |
f0e8a498b38f965754c666887ae93fb7d5d2b0ed | MrzvUz/python-in-100-days | /day-002/day-2-1-exercise.py | 1,440 | 4.4375 | 4 | '''Data Types
Instructions
Write a program that adds the digits in a 2 digit number. e.g. if the input was 35, then the output should be 3 + 5 = 8
Warning. Do not change the code on lines 1-3. Your program should work for different inputs. e.g. any two-digit number.
Example Input
39
Example Output
3 + 9 = 12
12
e.g... | true |
8467d45c9f556014374caff485162cbe8d314ec7 | MrzvUz/python-in-100-days | /day-008/day-8-2-prime_numbers.py | 1,865 | 4.21875 | 4 | '''Prime Numbers
Instructions
Prime numbers are numbers that can only be cleanly divided by itself and 1.
https://en.wikipedia.org/wiki/Prime_number
You need to write a function that checks whether if the number passed into it is a prime number or not.
e.g. 2 is a prime number because it's only divisible by 1 and 2... | true |
5efb9895e06699d9d2f5752779a144d73bcbd40c | CassMarkG/Python | /operations.py | 1,422 | 4.15625 | 4 | #Declaration of variables
a = 23
b = 12
c = 2.402
name = "Tshepo"
surname = "Gabonamang"
#Basic operations
full_name = name + surname #concatenate strings
sum = a + b
product = a*b
sumth = a**b #exponent
bb = b**2
divc = a / b
subtract = a - b
divs = a%b
#Assignment Operators
c += b
d = e = f = ... | true |
671220044cb30d7674abe64eb720fbcc42ae1043 | nhernandez28/Lab7 | /disjointSetForest.py | 2,168 | 4.21875 | 4 | """
CS2302
Lab6
Purpose: use a disjoint set forest to build a maze.
Created on Mon Apr 8, 2019
Olac Fuentes
@author: Nancy Hernandez
"""
# Implementation of disjoint set forest
# Programmed by Olac Fuentes
# Last modified March 28, 2019
import matplotlib.pyplot as plt
import numpy as np
from scipy impor... | true |
f7a3d0fb6075fb2b8de4735b927687651386f815 | octospark/100-Days-of-Code---The-Complete-Python-Pro-Bootcamp-for-2021 | /TurtleRace/main.py | 1,040 | 4.25 | 4 | from turtle import Turtle, Screen
import random
screen = Screen()
screen.setup(width=500, height=400)
user_bet = screen.textinput(title="make your bet", prompt="Which turtle will win the race? Enter a color: ")
colors = ["red", "orange", "yellow", "green", "blue", "purple"]
turtles = []
is_race_on = False
v... | true |
70c8efd8209fc40a4085139f86bdc57e11f01346 | roy355068/Algo | /Greedy/435. Non-overlapping Intervals.py | 1,667 | 4.15625 | 4 | # Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping.
# Note:
# You may assume the interval's end point is always bigger than its start point.
# Intervals like [1,2] and [2,3] have borders "touching" but they don't overlap each oth... | true |
54bd1b88a5ad75d1b4b7169cad68a4ee4aa5839b | roy355068/Algo | /Trees/109. Convert Sorted List to BST.py | 2,264 | 4.1875 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class ... | true |
4b44ac5cf8b0313a395dbcabd38f1bca1a3759b9 | roy355068/Algo | /Design Problems/341. Flatten Nested List Iterator.py | 2,279 | 4.1875 | 4 | # """
# This is the interface that allows for creating nested lists.
# You should not implement it, or speculate about its implementation
# """
#class NestedInteger(object):
# def isInteger(self):
# """
# @return True if this NestedInteger holds a single integer, rather than a nested list.
# :rt... | true |
312b5b4a69cf844e106f163e1168eefd5f708d18 | Siddhantmest/Data-Structures-and-Algorithms | /insertion_sort.py | 471 | 4.1875 | 4 | print('Welcome to the algorithm for Insertion Sort')
print('Input the list you want to sort, numbers separated by space:')
inplist = list(float(item) for item in input().split())
def insertionsort(a):
for i in range(1,(len(a))):
key = a[i]
j = i - 1
while (j >= 0) and (key... | true |
f9f8e7ffa801170f3e4ebcc8334335398756b439 | alaqsaka/learnPython | /madlibs.py | 828 | 4.125 | 4 | # Python project: madlibs
print("Welcome to madlibs game\n")
print("Madlibs is phrasal template word game which consists of one player prompting others for a list of words to substitute for blanks in a story before reading aloud.")
name = input("What is your name? ")
age = input("How old are you? ")
dreamJob = inpu... | true |
5b40cb33ef3132079b45b3db4a5c9d11ab3467a3 | BoomerPython/Week_1 | /DSA_BoomerPython_Week1.py | 649 | 4.1875 | 4 | # This file provides an overview of commands
# & code demonstrated in week 1 of the DSA 5061 Python course.
# Additional course materials depict the code shown here via
# the command line and also using a notebook.
# The basics - math
2+3
# Storing results
ans = 2 + 3
print(ans)
# Printing to the scr... | true |
80690807b5f4f514b81f2f4c7c104e2744bd64f1 | vivek2188/Study | /Datacamp/Python/Intermediate/Dictinoaries , Pandas/pandas_4.py | 645 | 4.15625 | 4 | '''
Your read_csv() call to import the CSV data didn't generate an error, but the output is not entirely what we wanted. The row labels were imported as another column without a name.
Remember index_col, an argument of read_csv(), that you can use to specify which column in the CSV file should be used as a row label? ... | true |
f7652c5bfc3bb0645c86615dace8ff63ae12d624 | ava6969/P0 | /Task2.py | 1,341 | 4.125 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
"""
TASK 2: Which telephone number spent the... | true |
f84e297229c0cabf70c42e2889358cb8403b389e | rahcode7/Programming-Practice | /Python/Concepts/Classes.py | 943 | 4.28125 | 4 | ## Classes & String Formatting
#def main():
#print("Before MyClass")
# class MyClass:
# variable = "temp"
# def f1(self):
# print("Message inside {0} {1} class".format("my","first"))
#myobject1 = MyClass()
# print(myobject1.variable)
#print(myobject1.f1)
# if __name__ == '__main__':
# myob... | true |
a61e1f86a84ad1e6cbcea3290f29bea3d5838683 | jamesli1111/ICS3U---PYTHON | /pythonquestions-fullprograms/question_1.py | 262 | 4.375 | 4 | '''
prompts user for 2 integers, divide them, and state remainder
'''
integer1 = int(input("Integer 1: "))
integer2 = int(input("Integer 2: "))
print(f"The quotient of {integer1} and {integer2} is {integer1//integer2} with a remainder of {integer1%integer2}")
| true |
b5ee90f664b959be85129db381087cf7950bb868 | sonalalamkane/Python | /Q6.py | 818 | 4.25 | 4 | # Question 6:
# Write a program that accepts a sentence and calculate the number of upper case letters and lower case letters.
# Suppose the following input is supplied to the program:
# Hello world!
# Then, the output should be:
# UPPER CASE 1
# LOWER CASE 9
# Hints:
# In case of input data being supplied to the quest... | true |
453d3fd5e296d4e654831da9d19808ef3644e49d | CodingGimp/learning-python | /RegEx/sets_email.py | 262 | 4.28125 | 4 | '''
Create a function named find_emails that takes a string. Return a list of all of the email addresses in the string.
'''
import re
def find_emails(s):
return re.findall(r'[-\w\d+.]+@[-\w\d.]+', s)
print(find_emails("kenneth.love@teamtreehouse.com, @support, ryan@teamtreehouse.com, test+case@example.co.uk")) | true |
3da13a6d7df49ccc0dd1fa2499a5c86c1ebf9383 | josbp0107/data-structures-python | /arrays.py | 1,487 | 4.34375 | 4 | from random import randint
import random
"""
Code used for Create an array in python
Methods:
1. Length
2. List representation
3. Membership
4. Index
5. Remplacement
"""
class Array:
"""Represent an Array"""
def __init__(self, capacity, fill_value=None):
"""
Args:
... | true |
6e65533248035d6bc795c08999bf995d0a66036d | gilgamesh7/learn-python | /conditionals/tstCond.py | 436 | 4.15625 | 4 | def tstIf(num1,num2):
if (num1 < num2):
retVal="{0} is less than {1}".format(num1, num2)
elif (num1 > num2):
retVal="{0} is less than {1}".format(num2,num1)
else:
retVal="{0} and {1} are equal".format(num1,num2)
return retVal
if __name__ == '__main__':
num1=i... | true |
34fadd2875a55ebb8120f48354b99d3b14262599 | Bobby-Wan/Daily-Coding-Problems | /problem27.py | 900 | 4.34375 | 4 | # This problem was asked by Facebook.
# 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 are_symmetrical(l... | true |
2a7ea48223400152b52a3846123a8e0d33ad0373 | Bobby-Wan/Daily-Coding-Problems | /problem7.py | 816 | 4.125 | 4 | # This problem was asked by Facebook.
# Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded.
# For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'.
# You can assume that the messages are decodable. For example, '001' ... | true |
23dc26b31f41fe446d251f868c6c9d8023ffd043 | Bobby-Wan/Daily-Coding-Problems | /problem29.py | 1,233 | 4.375 | 4 | # This problem was asked by Amazon.
# Run-length encoding is a fast and simple
# method of encoding strings. The basic idea is
# to represent repeated successive characters as
# a single count and character. For example,
# the string "AAAABBBCCDAA" would be encoded
# as "4A3B2C1D2A".
# Implement run-length encoding ... | true |
c1572b2f22444c58025bed5aadc12f1dcc5478cc | danielcinome/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/0-add_integer.py | 543 | 4.34375 | 4 | #!/usr/bin/python3
"""function that adds 2 integers.
Returns an integer: the addition of a and b
a and b must be integers or floats, otherwise raise a TypeError
exception with the message a must be an integer or b must be an integer
"""
def add_integer(a, b=98):
"""
a and b must be integers or flo... | true |
c7ccc320d1ef482d187b0c21fbb2803d6e508835 | ECE4574-5574/Decision_System | /phase_1/cache.py | 1,184 | 4.25 | 4 | """
Authored by Sumit Kumar on 3/22/2015
Description :
Decorator class - Caches output/return values of a function for a particular set of arguments,
by writing/reading a dictionary in the JSON format from a cache file.
Usage :
To use the caching capabilities, have the decorator coupled with the calling function ... | true |
5981f5d47820ce2cdf0ebfdf0a979d5a76bceb90 | Keitling/algorithms | /python/Math/newtons_sqrt_recursive.py | 1,318 | 4.375 | 4 | """
To compute sqrt(x):
1) Start with an initial estimate y (let's pick y = 1).
2) Repeatedly improve the estimate by taking the mean of y and x/y.
Example:
Estimation Quotient Mean
1 2 / 1 = 2 1.5 ((2 + 1) / 2)
1.5 2 / 1.5 = 1.333 1.4167 ((1.333 + 1.5) / 2)
1.4167 ... | true |
9f688ff6f0859d6c004c467cb76a8c6e5eb6d4a5 | Keitling/algorithms | /python/Sorting/insertion_sort.py | 1,408 | 4.28125 | 4 | def insertion_sort(alist):
return_list = alist
for index in range(1, len(return_list)):
value = return_list[index]
i = index - 1
while i >= 0:
if value < return_list[i]:
# Swap:
return_list[i + 1] = return_list[i]
return_list[i]... | true |
7ef864e9be1a823d3cfd0ff3fb192f67772f319f | Keitling/algorithms | /python/Recursion/recursion_vs_iteration.py | 1,967 | 4.1875 | 4 | # ----------------------------------------------------------------
# Measurement of running time difference between recursion
# and iteration in Python.
#
# To use this code from the command line:
# python recursion_vs_iteration.py number_of_tests test_depth
# For example, to make 100 tests with 200 recursion and
# it... | true |
7f5e24b711062965396d53c1c8b4345c2b6e2f69 | JoshMcKinstry/Dork_Game_team_octosquad | /dork/character.py | 1,614 | 4.125 | 4 | '''
A character module that creates an abstract representation of a character
'''
class Character():
'''
A class that models an character object
'''
def __init__(self, name, position, inventory):
self.name = name
self.position = position
self.inventory = inventory
def has_... | true |
6d462c11f9045377e64fc354d182761a64e1248b | nickbrenn/Intro-Python | /src/dicts.py | 755 | 4.28125 | 4 | # Make an array of dictionaries. Each dictionary should have keys:
#
# lat: the latitude
# lon: the longitude
# name: the waypoint name
#
# Make up three entries of various values.
waypoints = [
{
"lat": 43,
"lon": -121,
"name": "a place"
},
{
"lat": 41,
"lon": -123... | true |
f3d3ad6bf1b48814dd6a613d93b71e164b0e1b60 | theresaoh/initials | /initials.py | 409 | 4.15625 | 4 | def get_initials(fullname):
""" Given a person's name, returns the person's initials (uppercase) """
initials = ""
names = fullname.split()
for name in names:
initials += name[0]
return initials.upper()
def main():
user_input = input("What is your full name? ")
print("The initials ... | true |
9ad9da51c85299d9790c80d1c7301ba20de83eec | jereamon/non-descending-sort | /non_descending_sort.py | 1,685 | 4.375 | 4 | def non_descend_sort(input_array):
"""
sorts array into non-descending order and counts the number of swaps it took
to do so.
"""
swap_count = 0
while True:
# We'll need a copy of our array to loop over so we're not modifying
# the same array we're looping over.
input_ar... | true |
9e53024d91ab04a183c86568702f998adb035d3b | samuduesp/learn-python | /work/work.py | 677 | 4.125 | 4 | new = {}
numbers = int(input("how many numbers: "))
for i in range(numbers):
name =input("enter name of the person? ")
age =input("enter age of the person?")
bday =input("enter your bday?: ")
key = input("name")
value = input("enter value")
theme =input("enter year")
f... | true |
30bb1d3499fbb0a84409ae8b1abe12755dd69117 | rupol/Computer-Architecture-Lecture | /02_bitwise/bit_masking.py | 789 | 4.125 | 4 | instruction = 0b10100010
# shifting by 6 should leave us with first two values
shifted = instruction >> 6
# print(bin(shifted)) # 0b10
# what if we wanted to extract the two numbers in the middle?
# first, convert so the bits in the middle are the last two digits
shifted = instruction >> 3
# print(bin(shifted)) # 0... | true |
c4cb355044d3e5c03ad2038193af42832b91ffbc | samratkaley/Developer | /Python/07_List.py | 972 | 4.28125 | 4 | # list Declaration:-
list1 = ["Samrat","Omkar",50,315,500];
print (list1);
list2 = [1,2,3,4,5,10];
list3 = [9,8,6]
list4 = list1 + list2; # Concatenate two list
print (list4);
print (list1[2:4]); # print Range list
print (list1[2:3]+list2[4:5]); #Concatinating two number from range
print (list1[2]+... | true |
9924ed16860c153be1779753b7e31d51cf1b229f | ethan-mace/Coding-Dojo | /Python v4/Python Fundamentals v4/Python Fundamentals/Functions Basic 1/functions_basic1.py | 1,932 | 4.25 | 4 | # #1 Prints 5
# def a():
# return 5
# print(a())
# #2 Prints 5 + 5
# def a():
# return 5
# print(a()+a())
# #3 Prints 5. 'return' ends the functions prior to the next line
# def a():
# return 5
# return 10
# print(a())
# #4 Same as #3
# def a():
# return 5
# print(10)
# print(a())
# #5 Prin... | true |
668c178f0cbe2ee64a0041d5ed97c2ab271614c5 | yuryanliang/Python-Leetcoode | /Daily_Problem/20191004 Count Number of Unival Subtrees.py | 911 | 4.21875 | 4 | """Hi, here's your problem today. This problem was recently asked by Microsoft:
A unival tree is a tree where all the nodes have the same value. Given a binary tree, return the number of unival subtrees in the tree.
For example, the following tree should return 5:
0
/ \
1 0
/ \
1 0
/ \
1 1
The... | true |
145d92f103d9191f48c5646c0ea84b7c098d6eca | yuryanliang/Python-Leetcoode | /recursion/101 symmetric tree.py | 1,605 | 4.375 | 4 | """
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).
For example, this binary tree [1,2,2,3,4,4,3] is symmetric:
1
/ \
2 2
/ \ / \
3 4 4 3
But the following [1,2,2,null,3,null,3] is not:
1
/ \
2 2
\ \
3 3
"""
# Definition for a bin... | true |
f67082924240fd2b8dd73006bde9e35a005342ba | yuryanliang/Python-Leetcoode | /100 medium/6/299 bulls-and-cows.py | 2,780 | 4.25 | 4 | """
You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called "bulls... | true |
a551c51e0aba623ab79b53dc7b9ea1c039f1e3cc | ZdenekPazdersky/python-academy | /Lesson8/8.49_prime_numbers.py | 2,704 | 4.46875 | 4 | # ####2DO
# Your goal in this task is to create two functions:
#
# 1. list_primes
# Function that will list all the prime numbers up to the specified limit, e.g. list_primes(10) will list all the prime numbers from 0 to 10 including. The function should return a set or a list of prime numbers found.
#
# Example of usin... | true |
461dee7e05ee938b79e15b20ef369149601d91ba | ZdenekPazdersky/python-academy | /Lesson1/1.7-List.py | 1,435 | 4.3125 | 4 | #2do
# Create script, which will:
#
# assign an empty list to variable candidates,
# print the content of variable candidates introducing it with a string 'Candidates at the beginning:',
# assign a list to variable employees, containing strigns: 'Francis', 'Ann', 'Jacob', 'Claire',
# print employees content introducing... | true |
f6174ef98fe1c5fbe6b16402f882c82c8e9e39ea | ZdenekPazdersky/python-academy | /Lesson1/1_buying_cars.py | 929 | 4.375 | 4 | # ###2do
# #In the Python window you already have Mercedes and Rolls-Royce prices listed (don't forget to covert string to integer!). In addition, you have to create a variable that will ask the user for the extra cost. Then you will need to calculate:
# The price for two Mercedes,
# The Mercedes and Rolls-Royce prices... | true |
05b84ffa87c8d326935e1ac2aab5f0e027d9b5e0 | ZdenekPazdersky/python-academy | /Lesson7/7.41_reversed.py | 978 | 4.40625 | 4 | ####2DO
# Your task is to create a function that will imitate the built-in function reversed(). It will take any sequence as an input and will return a list of items from the original sequence in reversed order.
#
# Example of using the function:
#
# >>> reversed(range(10))
# [9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
# >>> revers... | true |
eb7e32e6c9d29fe746f5e48e3cc82bd0ae3f7018 | 4BPencil/hello-world | /salary_with_try_except_loops.py | 491 | 4.15625 | 4 | #asking for input
h=input("hours: ")
r=input("rate: ")
#nutrilizing input errors
try:
ih=float(h)
ir=float(r)
except:
ih=-1
ir=-1
#re-asking for input if there are some errors
while ih==-1 or ir==-1:
print("Please enter a numerical value")
h=input("hours: ")
r=input("rate: ")
try:
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.