blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
9d5221025793a274527849a8ffb3ab3621fc05b6 | VimanyuAgg/dsand | /Lesson3_submissions/problem_2.py | 2,744 | 4.40625 | 4 | def rotated_array_search(input_list, number):
"""
Find the index by searching in a rotated sorted array
Args:
input_list(array), number(int): Input array to search and the target
Returns:
int: Index or -1
"""
if (not input_list) or (not number): # return -1 if input_list is None ... | true |
b12836abaf970e904e2fc03c1d1c4c2b434add19 | Morozov256/Base-case | /changeSymbol.py | 2,046 | 4.5625 | 5 | def startChanging(string, symbol):
'''
The method for start.
Prints all possible options to replace each of the specified characters in the string
with the remaining characters in the string
:param string: the string for replacing
:param symbol: the specified character
:return: nothin... | true |
1b947b59895c3ff0fa56d3769eabafdffdd51e98 | lakshmanamettu/CS5590-Python-DL-Session2 | /Lab1/Source/que3.py | 779 | 4.125 | 4 | P = input("enter names of students in python class:")
Python = set(P.split(" "))# input get sepearted by spaces between them
#print(Python)
# list of students who took web
W = input("enter names of students in Web class:")
web = set(W.split(" "))
#print(Web)
# printing the common students who took both python and we... | true |
f0663320ae56bdc284a255cc33bd5cfd1596e17b | AlphaLFC/captcha | /utils/listutils.py | 1,492 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created by PyCharm.
@Date : Sat Dec 16 2017
@Time : 18:15:36
@File : listutils.py
@Author : alpha
"""
def charlist(in_list):
"""
Convert a list of strings to a list of separate chars.
# Example
param in_list: ['', 'abc', 'd']
r... | true |
41274765e5ecd387c06bcd73471601343e6f7f61 | SarthakDeora/Python-Course-2 | /06_Functions_of_String.py | 1,973 | 4.40625 | 4 | string1 = "My name is Sarthak Deora"
print(string1) # ? Her i Just printed the the variable string1
# ?So this is how you can print a specific digit but python doesnt start counting from1 it starts counting from 0
print(string1[7])
print(string1[0:7]) # ? So this will help us by printing from a desired plsce to... | true |
189ed4c882e0ef8def8088c767990adce35c9b20 | SarthakDeora/Python-Course-2 | /Exercise_02.py | 875 | 4.3125 | 4 | # # Exercise 2--------> To make a falty calculator which will give all the correct answers Except the following--> 45*3=555, 56+9=77, 56/6=4
print("Hello I am your Calculator!!")
number1 = int(input("Type your 1st number: "))
operator = input("Type your operator: ")
number2 = int(input("Type your 2nd number: "))
if... | true |
f16efbcbb403f4969d136f03c5ed88000361d880 | kevinwing/coderbyte-solutions-python | /easy/first_reverse.py | 554 | 4.25 | 4 | #!/usr/bin/env python3
"""
Challenge:
Have the function FirstReverse(str) take the str parameter being passed and
return the string in reversed order. For example: if the input string is
"Hello World and Coders" then your program should return the string sredoC
dna dlroW olleH.
Sample Test Cases:
Case 1:
... | true |
c4d755709d8aa5fbbf53bb154885f61f85cb03de | whiteshadow9858/Eligibility-for-voting | /newfile.py | 202 | 4.125 | 4 | print ('Can you vote , lets check')
name = input('Enter name ')
age = int(input("Enter Age (only numbers): "))
if age>=18:
status="can"
else:
status="can not"
print( name,status," Vote.")
| true |
115461b2e87a42a27f9b5fe354da0f51daedc998 | rohinrohin/python-lecture | /Day 2/Lecture/1_validate_date.py | 567 | 4.125 | 4 | # validate the date
temp = [
None, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
]
#days = [temp, temp] # creates aliases
# changing days[1] affects days[0] and temp
days = [temp[:], temp[:]]
days[1][2] = 29
print(days[0])
print(days[1])
line = input('enter the date dd/mm/yyyy : ')
(dd, mm, yy) = line.split('/')
... | true |
4b4bb6a3ae45d37a19d8fde8d90f7b53f3279932 | ottoguz/Simple-Shopping-List-with-Python | /aula006j.py | 1,563 | 4.25 | 4 | #A simple supermarket shopping list
shopping_list = []
# Sum is the counter to add up the total price at the end of the program
sum = 0
#Lines to enter data (Item name, quantity and Unit price)
print('SHOPPING LIST')
print('Press ENTER to finish the list.')
while True:
item_name = str(input('Item:'))
... | true |
0b6fac21b2f483171082744a7e9092430b095e9f | sforrester23/rock_paper_scissors | /RPS_functions.py | 313 | 4.25 | 4 | # function to change user input of Rock, Paper or Scissors into a corresponding number, so it can be compared with a random number generated by computer
def rock_paper_scissors(word):
if word == "Rock":
return 1
elif word == "Paper":
return 2
elif word == "Scissors":
return 3
| true |
6bd87c9ab19ed9a19b8485a1da39a4e6e057f389 | SpencerZahn/Daily-Python-Exercise-01 | /Daily Exercise 3 020818.py | 945 | 4.5 | 4 | #Spencer Zahn - Python Daily Exercise 3 - 020818
#3 Write a program that prints out the numbers from 1 to 20.
# For multiples of three, print "usb" instead of the number and for the mulitiples of five, print "device".
# For numbers which are multiples of both three and five, print "usb device".
# Print a new li... | true |
9a83e250116b6b3b71ce03d3f51924efa67d6083 | Eguzkiman/progras-notes | /ejercicios/poker.py | 1,179 | 4.21875 | 4 | """
Escribe un programa que defina las siguientes clases:
1) Card
Properties:
value (integer from 1, 13)
suit ('hearts', 'diamonds', 'spades', 'clubs')
2) Deck
Properties:
cards (list of cards)
Methods:
shuffle (shuffles the cards)
make_hand (returns a new hand with five cards)
Ejemplo:
my_deck = Deck()
De... | true |
6016b04eaf66d481ef34686cb3614d933453ef45 | ben-whitten/ICS3U-Unit-3-06-Python | /number_guessHD_update2.0.py | 1,346 | 4.15625 | 4 | #!/usr/bin/env python3
# Created by: Ben Whitten
# Created on: October 2019
# This is a program which makes you guess a number.
import random
class color:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'... | true |
2a70c977aab657e7edfde54e3f5a3db3a7331f10 | ForeverW/python_work | /ehand.py | 343 | 4.1875 | 4 | def add_demo():
try:
num1 = input("Input an number : ")
num1 = int(num1)
num2 = input("Input an number : ")
num2 = int(num2)
sum_num = num1 + num2
except TypeError:
print("Please input a number")
else:
print('The sum of the input number is : '+ str(sum... | true |
5646d7b7cc9735aaa535fbdb38a226553534be66 | dariusrenj/Python | /Python/lab2g.py | 1,922 | 4.53125 | 5 | """
Name: Zackery Vering
Project: Lab 2G: Planets Exercise
Date: 5 Sept 2018
Recommended Version: Python 2.7
Instructions:
-Follow TODO's below
"""
planet_string = "Mercury|Venus|Earth|Mars|Jupiter|Saturn|Uranus|Neptune"
#TODO: Convert planets_string to a list, save it to planet_list.
#changed it so planet_list goes ... | true |
c16fbf04adaa09ba9d0f3284c93bf1233c79407f | dariusrenj/Python | /Python/lab3f.py | 1,393 | 4.1875 | 4 | """
Name: Zackery Vering
Project: Lab 3F FizzBuzz
Date: 10 Sept 2018
"""
#start loop that goes from 1 to 100
for i in range(1, 101):
#if i is divisible by 3 and 5 print FizzBuzz
if ((i % 3 == 0) and (i % 5 == 0)):
print ("FizzBuzz")
elif (i % 3 == 0):
#if i is divisible by 3 but not 5 print ... | true |
856cf639e254a3c3351eb5123fe1362c49fcfe08 | jayshreevashistha/forskml | /Coding Challenge/Day_2/reverse.py | 395 | 4.34375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed May 8 20:44:16 2019
@author: computer
"""
def reverse(inputString):
stringLength = int(len(inputString))
reversedString = ""
for i in range(0,stringLength):
reversedString = reversedString+inputString[-i-1]
print (str(reversedString))
string... | true |
12e921563f805c82bcb41547389623397dc8fbee | pgroves95/digitalcrafts-03-2021 | /week1/day_3/calc.py | 1,405 | 4.25 | 4 | print("""This program performs integer arithmetic.
It takes a number, an operator, and another number,
then displays the result of the operation.\n""")
def entry():
op_list = []
prompt = ''
prompt = input("Type a number >> ")
try:
prompt = int(prompt)
op_list.append(prompt)
... | true |
e419bfee11ebf56e0088502b4b10dfd7abb0b7df | ankitboss/Python_Program | /variable1.py | 1,095 | 4.25 | 4 | #Declearing variable
x=5
y=7
z=3
print(x,y,z)
#multiple assignment
x=y=z=8
print(x,y,z)
#multiple assignment to multiple variable
x,y,z=2,3,4
print(x,y,z)
#some fundamental
''' 1.token and their type
2.comment
1. (a)token can defined as punctuator mark,reversed words and each individual word in... | true |
5342c63e0f9b07209803deabb7f2305db43a6057 | mrhwick/PythonAssessmentAnswers | /question1/question1.py | 928 | 4.21875 | 4 | '''
Created on May 30, 2014
Prints all of the numbers from 1 to 107, each on a separate line, without taking input.
For all multiples of 3, Fizz is printed in its place.
For all multiples of 5, Buzz is printed in its place.
For all multiples of both 3 and 5, FizzBuzz is printed in its place.
@author: MRHardwick
'''
... | true |
e33986254f0900d135343df9e4bf3924b38ffd86 | jassskalkat/bill_splitter | /main.py | 1,427 | 4.125 | 4 | # bill_splitter is a program that splits the bill amount somewhat among friends.
# The program keeps the fun alive and makes sure that everyone pays an equal amount.
import random
num_of_friends = int(input("Enter the number of friends joining (including you):\n"))
print()
friends_dictionary = {}
# nothing to do if... | true |
e5f93831ccc903b08007453f6284b71c8c3ec79e | jasminechin12/CSSI | /Python/more_practice.py | 354 | 4.1875 | 4 | input = raw_input("Please input x: ")
#x = int(input)
#what if input is "abc" instead?
try:
x = int(input)
except Exception as ex:
print "x is invalid"
exit()
if x > 500:
print "x is really big"
elif x <= 500 and x > 50:
print "x is sort of big"
elif x < 0:
print "x is negative"
else:
... | true |
7c9ae89cb773c17c562f330a60c3440712e4f908 | ndhamne/PythonPractise | /HackerRankChallenge/2_if_else_1.py | 969 | 4.34375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 21:54:27 2020
@author: nikhildhamne
Task
Given an integer, n, perform the following conditional actions:
- If n is odd, print Weird
- If n is even and in the inclusive range of 2 to 5, print Not Weird
- If n is even and in the inclusive range of... | true |
1cae62c41ccff4caaf7c49f1ccbf6b36982a9adc | dimpho-m/OOP-Dice-Game | /DicePoker.py | 2,433 | 4.21875 | 4 | #import packages needed
import random
class Die:
""" This is a class that initializes the 5 die used to play the game"""
# We assume that the game is being played with a regular 6-sided dice. We initialize each dice to start at 0
def __init__(self, die):
self.die = [0] * 5
# define a method that roll... | true |
6258513f3dba788704576d623fb3927af2ad4a62 | SwarupKarmokar/python-swarup | /python_string.py | 1,713 | 4.40625 | 4 | # python support both single and double quotes because python is very flexible
my_string = 'my name is swarup karmokar'
print(my_string)
my_string = "my name is swarup karmokar"
print(my_string)
# now try
#my_string = 'kalu and lalu are swarup's pets'
# its shows error because when the single quote end python interpr... | true |
8548bc1fd533700ad9418ae3c701ecd2e25b4aee | SwarupKarmokar/python-swarup | /map_and_filter_function_in_python.py | 1,046 | 4.4375 | 4 | # map function: map function allows us to 'map' a iterable object so we can quickly call the same function for every iterable object
# def squre_num(num):
# return num ** 2
# my_num = [1, 2, 3, 4]
# ans = squre_num(my_num)
# print(ans) # it shows an error unsupported operand types
# for this problem we using ma... | true |
b5395a0c4bda59b1c86d466264d26c2e39ef6c70 | clicianaldoni/aprimeronpython | /chapter3/3.11-weekday.py | 676 | 4.25 | 4 | """
Exercise 3.11. Look up calendar functionality.
The purpose of this exercise is to make a program which takes a
date, consisting of year (4 digits), month (2 digits), and day (1-31) on the command line and prints the corresponding name of the weekday (Monday, Tuesday, etc.). Python has a module calendar, which you m... | true |
53ec9e9c6870daea6ce6c936384e832d76381b96 | Nandagopan-Gopi/Algoexpert-Leetcode | /arrays_leetcode/Merge_Intervals.py | 1,016 | 4.1875 | 4 | """
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
Example 1:
Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since interv... | true |
79bf89d297b32feecc4e14b7ebeffeb1dec4db39 | aligeekk/algorithms | /Level-2/remove_obstacle.py | 2,007 | 4.125 | 4 | #!/usr/bin/python
# Date: 2018-07-25
#
# Description:
# You are in charge of preparing a recently purchased lot for one of amazon's
# new building. The lot is covered with trenches and has a single obstacle that
# needs to be taken down before the foundation can be prepared for the building.
# The demolition robot mus... | true |
27376a24fd5821be22d92ed4d323b59c3de5dc5e | myorg2020/python-tutorial | /day4/for_loop_sum.py | 277 | 4.15625 | 4 | #!/usr/bin/env python
# sum of 1 to 10
# 1+2+3+4+....
total = 0
for i in range(1,11):
total += i
print(total)
# Now we will ask user to give input and will sum:
number = int(input("Enter the number: "))
total = 0
for i in range(1,number+1):
total += i
print(total)
| true |
646f01302fe54ec0e954627aa1a8993c95010e5b | myorg2020/python-tutorial | /day7/exercise1.py | 216 | 4.125 | 4 | # This program is for getting a dictionary values cubes of keys, i.e
# {1: 1, 2: 8, 3: 27}
def cube_finder(n):
cube = {}
for i in range(1,n+1):
cube[i] = i**3
return cube
print(cube_finder(10))
| true |
2121c233d4f6566da68a5de2f521e406daada4a7 | myorg2020/python-tutorial | /day7/update_dict.py | 928 | 4.625 | 5 | #!/usr/bin/env python
user_info = {
'name' : 'Amitesh',
'age' : 30,
'fav_movies' : ['coco', 'kimi no na wa'],
'fav_tunes' : ['awakening', 'fairy tale'],
}
more_info = {'State' : 'Bihar', 'hobbies' : ['tech', 'cricket', 'music']}
# suppose we want to add the dictionary more_info into the dictionary u... | true |
551c495a4e75a77523d2109b2746ec0262d17a24 | myorg2020/python-tutorial | /day5/exercise1.py | 286 | 4.25 | 4 | #!/usr/bin/env python
def greater_than(a,b):
if a>b:
return a
return b
number1 = int(input("Enter the 1st number: "))
number2 = int(input("Enter the 2nd number: "))
result = greater_than(number1, number2)
print(f"greater between {number1} and {number2} is: {result}")
| true |
60e7a1d35fdd78a789ed61d676e7a9bbbccfc0ff | myorg2020/python-tutorial | /day7/final_tuple.py | 990 | 4.5 | 4 | #!/usr/bin/env python
# we can use range func to create tuple like list:
tupes = tuple(range(1,10))
print(tupes) # we get a tuple: (1, 2, 3, 4, 5, 6, 7, 8, 9)
print(type(tupes)) # verify the type: <class 'tuple'>
print("\n")
# To convert a tuple into list
nums = (1, 2, 3, 4, 5, 6, 7, 8, 9)
nums = list((1, 2, 3, 4, 5... | true |
0a7089e322ec46cb2cad982d9ca8acf171430674 | myorg2020/python-tutorial | /day10/enumerate_func.py | 998 | 4.65625 | 5 | # we use enumerate function with for loop to track the position of our items in a list/tuple.
# Using normal for loop also we can track the position of our items in a list/tuple.
# Normal way:
name = ['abc', 'abcdef', 'amitesh']
# Suppose we want to get the items of our list using position, like below
# 0 : abc
# 1 : ... | true |
65d73bf519b52aa2ab5a8d817900bce43e6531cd | myorg2020/python-tutorial | /day4/infinite_loop.py | 488 | 4.25 | 4 | #!/usr/bin/env python
#sometime by mistake we run infinite loop, like below. suppose we don't write line #8. it will go in infinite loop
# i = 0
# while i <= 10:
# print("hello world")
# i += 1
# suppose if want to intentionally write infinite loop, use:
while True:
print("Hello World")
# There 2 bina... | true |
7e17c8bfdc7bc0e8643c88bb68b06535f9fc0188 | myorg2020/python-tutorial | /day10/zip_func.py | 1,709 | 4.90625 | 5 | #!/usr/bin/env python
user_id = ['user1', 'user2', 'user3']
names = ['amitesh', 'saanvi', 'manisha']
# Suppose i want to combine userd id and names, means user1 as amitesh, user2 as saanvi and so on...
# we can use zip() function
print(zip(user_id, names)) # It just prints <zip object at 0x10afb3f50> as zip object
p... | true |
99f5b9788fbfc029caa5bc235e27a6f4d63ae505 | myorg2020/python-tutorial | /day9/exercise1.py | 476 | 4.25 | 4 |
# lis = ['abc', 'tuv', 'xyz'] -> ['cba', 'vut', 'zyx']
# Normal method:
words = ['abc', 'tuv', 'xyz']
opposite = []
for i in words:
opposite.append(i[::-1])
print(opposite)
print('\n')
# Using List comprehension:
opposite_list = [i[::-1] for i in words]
print(opposite_list)
print('\n')
# Using above same login... | true |
34eec8629182a85217a14b4f521568a6b399c5b5 | Afsalms/learn_python | /datastructures/arrays/bubble_sort.py | 670 | 4.15625 | 4 | from random import shuffle
"""
Simple sort algoritm
compare each element with the other element
application: For academic purpose only
"""
def bubble_sort_algorithm(a):
number_of_iteration = 0
for i in range(len(a)-1):
swapped = False
for j in range(len(a)-1-i):
number_of_iteratio... | true |
77c936d3cb56218bede868029ddc16584b1ffcc3 | heidipaulson/python-lessons | /mp_1/week_1/3_string_manipulation_todo.py | 686 | 4.1875 | 4 | """
Personality questionnaire
"""
# write a program that asks a user 6 unique questions about them and see if it works!
# use input functions however you would like
first_name= input("What is your first and last name?")
major= input("What is your major?")
graduation= input("When is your graduation date?")
fav_class= i... | true |
9cd151b95ea9ba930dd3742ccfbbdb1d031def5e | bugg86/Calc | /calculator_v1.py | 1,540 | 4.25 | 4 | loops = True
def loop(): # defines the whole program as a function
first_number = input("Please enter your first number: ") # stores the first number as a variable
def add(): # the addition function
second_number = input("Please enter your second number: ") # stores the second number ... | true |
af0eb0e2f22cff9b9d6366c4a8bee79a8e51e214 | UkrainianEngineer/programming_education | /oleksijt/Task2_finding_cheapest_book.py | 765 | 4.3125 | 4 | """This script should find and return the cheapest book from dictionary
in format:
`The cheapest book is ‘Fluent Python’. It costs 650 grn.`
"""
# Initialize dictionary with books.
books = [{
'name': 'Lord of the rings',
'price': 700
},
{
'name': 'Harry Potter',
'price': 13... | true |
e50c72220ecbfb9026843d46f4f888266fab888b | UkrainianEngineer/programming_education | /olya_petryshyn/task0008_finding_the_longest_word.py | 388 | 4.40625 | 4 | """
Finding the longest word in the file.
"""
import string
file_name = 'textfile.txt'
def the_longest_word(file_name):
with open(file_name, 'r') as file:
string_text = file.read().replace('\n', ' ')
string_text = string_text.translate(None, string.punctuation)
list_text = string_text.split()
... | true |
4c1aadbde967ea6afe5036edd5f1493883818c05 | thanhcongnguyen/learn.python | /lists.py | 796 | 4.5625 | 5 | #Lists are very similar to arrays.
#They can contain any type of variable, and they can contain as many variables as you wish.
#Lists can also be iterated over in a very simple manner. Here is an example of how to build a list.
myList = [];
myList.append(1);
myList.append(2);
myList.append(3);
print(myList[0]);
prin... | true |
6f4b4bb14bfdc203302a69d521a843a851456d24 | TenzinTsundue/100daysofcode | /day2.py | 498 | 4.34375 | 4 | #Tip calculator
#total bill, tip percentage, how many people
#each person should pay as an out put
total_amount = float(input("what is the total bill: "))
discount_percent = int(input("what % of tip you want to give eg:10, 15, 20? "))
no_of_people = int(input("how many people to split the bill : "))
total_pa... | true |
5ac54754261aa08c726c824943a08098d584e5be | drius-22/python_scripts | /Breath_First_Search/min_depth_binary_tree.py | 1,289 | 4.15625 | 4 |
# Given a binary tree, find its minimum depth.
# The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
# Note: A leaf is a node with no children.
# https://leetcode.com/problems/minimum-depth-of-binary-tree/
class TreeNode:
def __init__(self, val=0, l... | true |
5d2766e0b2e096024575916bcdfa84d347f074bf | evamaina/practice | /bin.py | 582 | 4.78125 | 5 | """use print and bin() to print out the binary
representations of the numbers 1 through 5,
each on its own line."""
print bin(1)
print bin(2)
print bin(3)
print bin(4)
print bin(5)
""" In order to print a number in its binary representation,
you can use the bin() function. bin() takes an integer as
input and ret... | true |
07716b83ef957c27797f9ec05e17502c036e95f0 | tanmay1122/python-cheatsheets | /filter.py | 493 | 4.125 | 4 | # filter function can use only 1 iteration that is can use only 1 loop
# but when we canvert into list or a tuple the we can iterated as we want
def is_even(a):
return a%2==0
num=[1,4,6,7,8,9,3,3,5]
event=list(filter(is_even,num))
for i in event: # first print
print (i)
print(event) #... | true |
4d210f24cc032f954b21b5abb80de30af25aa7e7 | tangothu/Python-Leetcode | /substringWithKUniqueCharacters.py | 1,380 | 4.34375 | 4 | # Python3 program to count number of
# substrings with exactly k distinct
# characters in a given string
# Function to count number of substrings
# with exactly k unique characters
def countkDist(str1, k):
# Initialize result
res = 0
# Consider all substrings beginning
# with str[i]
result = []
... | true |
4ef65c59196a345d7842948b9cd6a14dcbbf0c4c | csfranze/PythonCodewars | /last_digit_of_large_number.py | 1,186 | 4.28125 | 4 | #Define a function that takes in two non-negative integers a and b and returns the last decimal digit of a^b. Note that a and b may be very large!
#For example, the last decimal digit of 9^7 is 9, since 9^7 = 4782969. The last decimal digit of (2^200)^(2^300), which has over 10^92 decimal digits, is 6. Also, please ta... | true |
d3b68f744aef143505f13d370e675219ff1ce11d | csfranze/PythonCodewars | /counting_duplicates.py | 948 | 4.34375 | 4 | #Count the number of Duplicates
#Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits.
#Example
#"abc... | true |
88a260063f060b5a05bf5dfcacfc3f5dc89d605f | yvonnendutaw/python-guide | /modify_sring.py | 637 | 4.15625 | 4 | #!/usr/bin/env python2
#this function accepts a variable that will be called original in the scope
def modify_string(original):
original += "that has been modified"
#here only the local copy has been modified
def modify_string_return(original):
original += "that has been modified"
return original
#return... | true |
c8c0697c870829e111e05179227a2736f9f73059 | Honza-m/python-training | /Workshop 1/1.0 - First function.py | 671 | 4.34375 | 4 | def area_comparer(x:float, y:float) -> str:
""" Calculates area of a square from x & y coordinates and returns an info
message
Args: x - length of the square (metres)
y - height of the square (metres)
"""
result = x * y
if result > 50:
return "Square is bigger than... | true |
df437ed01eb78579806d6ff0254ad839a872b4d7 | yukti99/Chatbot | /model.py | 923 | 4.125 | 4 | import torch
import torch.nn as nn
# Feed-forward Neural Network with two hidden layers
class NeuralNet(nn.Model):
def __init__(self,input_size,hidden_size, num_classes):
super(NeuralNet,self).__init__()
self.l1 = nn.Linear(input_size,hidden_size)
self.l2 = nn.Linear(hidden_size,hidden_size... | true |
9460a4b516d7015362f27ad13629548772b2d054 | GopalSawant/Python_Image_processing | /First/BuiltInModuleGame.py | 999 | 4.21875 | 4 | import random
def user_number_validation(number):
while number > 10 or number < 1:
number = int(input("Please Enter integer number between 1 to 10: "))
return number
while True:
user_number = int(input("Enter integer number between 1 to 10: "))
user_number_validation(user_number)
system_... | true |
1296ef748856cf41dbf129ea861cf11a1346fda0 | littlediobolic/python-practice | /sort.py | 751 | 4.28125 | 4 | #!/bin/bash/python
#Practicing insertion sort
#By Diobolic
import random
#Initialize
unsorted_array = []
length = int(input("Please input length of array to sort: "))
count = 0
while count <= length:
unsorted_array.append(random.randint(-10000,10000))
count += 1
#Presort
print("Unsorted Array: " + str(unsor... | true |
9088d4aad8f81c1cd44d2911a634e6e13d8c2387 | MerinGeorge1987/PES_PYTHON_Assignment_SET2 | /ass2Q29_2.py | 933 | 4.21875 | 4 | #!/usr/bin/python
#Title: Assignment2---Question29_2
#Author:Merin
#Version:1
#DateTime:28/11/2018 6:45pm
#Summary: Apply all built in functions on Strings in your program. Note:There are 40 string functions. Use Tutorial for the help.
# Note: Each program should have 5 string built in functions
#Use... | true |
b06db4c52de128bb26d0464ab90f9c561317cde7 | MerinGeorge1987/PES_PYTHON_Assignment_SET2 | /ass2Q29_1.py | 1,414 | 4.34375 | 4 | #!/usr/bin/python
#Title: Assignment2---Question29_1
#Author:Merin
#Version:1
#DateTime:28/11/2018 6:45pm
#Summary: Apply all built in functions on Strings in your program. Note:There are 40 string functions. Use Tutorial for the help.
# Note: Each program should have 5 string built in functions
#Use... | true |
161b666c1c1bac92832ff9ceee0fe503e1fa7836 | MerinGeorge1987/PES_PYTHON_Assignment_SET2 | /ass2Q31.py | 1,412 | 4.40625 | 4 | #!/usr/bin/python
#Title: Assignment2---Question31
#Author:Merin
#Version:1
#DateTime:24/11/2018 4:30pm
#Summary:Write a program to search an element in the list.
# i.e. Perform the binary search on the sorted list having integers as elements.
# If the search is successful print "Success" else pr... | true |
639caf312144d08071d8f48d78b17e5221943b21 | apri-me/python_class00 | /session9/tamrinha/tamrin3.py | 329 | 4.1875 | 4 |
def caps_and_smalls(text):
up = 0
low = 0
for ch in text:
if ch.isupper():
up += 1
elif ch.islower():
low += 1
return up, low
string = input("Enter your text: ")
up, low = caps_and_smalls(string)
print("Your text contains {} upper(s) and {} lower(s).".format(u... | true |
f7661563c6fe0e7b68cd5a1192d9d504dcc0cbb2 | shivaji50/PYTHON | /LB4_1.py | 543 | 4.25 | 4 | # a program which accept number from user and display its multiplication of
# factors.
# Input : 12
# Output : 144 (1 * 2 * 3 * 4 * 6)
# Function name : Factor()
# Author : Shivaji Das
# Date : 21 august 2021
def Factor(no):
mult=1
if no <= 0:
return
for i in range(1,no):
... | true |
7f268126168c7855460f154d851f25bd31188aaa | shivaji50/PYTHON | /Program42.py | 325 | 4.25 | 4 | # A program to create one array from another array and multiplying the elements
# of first array by 3 before storing it into the second array
from array import *
arr1 = array('i',[100,200,300,400])
print('The first array ',arr1)
arr2 = array(arr1.typecode,(a * 3 for a in arr1))
print('The second array',arr... | true |
4a070d5d07662b98547b471848568af0339b1b05 | shivaji50/PYTHON | /LB6_5.py | 585 | 4.125 | 4 | # a program which accept number from user and count frequency of such a
# digits which are less than 6.
# Input : 2395
# Output : 3
# Function name : Digit()
# Author : Shivaji Das
# Date : 24 august 2021
def Digit(no):
cnt=0
if no < 0:
no=-(no)
while no > 0:
digit=int(no%1... | true |
8b0327c20835a957e1b8f98d80873c4d9034f724 | Chirag1997aggarwal/plugins | /python/advance_python/decorators.py | 1,046 | 4.5625 | 5 | # Resource - https://www.python-engineer.com/courses/advancedpython/13-decorators/
# A decorator is a function that takes another function and extends the behavior of this function without explicitly modifying it.
# It is a very powerful tool that allows to add new functionality to an existing function.
# There are 2... | true |
d6c5d19a2be996fba74addf565c3afc389a3b74d | guptankit6252/Data-Structures | /oprators.py | 697 | 4.46875 | 4 | #OPERATORS IN PYTHON :
#Arithmetic operator
#Assignment operator
#Comparison operator
#Logical operator
#Identity operator
#Membership operator
#Bitwise operator
#Arithmetic operators
print("5+6 is", 5+6)
print("34//9 is", 34//9) # Integer values , ** is exponent
#Assignment operator
x = 5
print(x... | true |
7d1abefdc4a6e21879bd13c42fab31d8aacd0ef6 | jonnybazookatone/csnoncs | /bs_iterative.py | 1,470 | 4.1875 | 4 | """
Binary search algorithm, iterative example
"""
def binary_search(array, value):
left = 0
right = len(array)
centre = (right + left)/2
while left < right:
if array[centre] == value:
return centre
if value > array[centre]:
print 'Centre [{}] < value [{}... | true |
e6b9c2befebf8b845ee785b5831211a68da2ac79 | OlehHnyp/test_controller | /tasks/task_086a.py | 811 | 4.71875 | 5 | from additional_functions import is_positive_integer
def count_symbols(string):
"""
This function counts the number of symbols in string.
"""
return len(str(string))
def task_086a():
"""
This function prints the number of digits in inputted positive integer.
"""
print(task_086a.__doc... | true |
af1475ef67742d29ec3cbc127a9912a14beeeabb | csaszarhunor/Python-Hard-Way | /ex33.py | 661 | 4.28125 | 4 | # http://learnpythonthehardway.org/book/ex33.html
def list_creator(incrementor):
i = 0
numbers = []
top = 15
while not(incrementor.isdigit() and int(incrementor) > 0):
print("Enter a positive integer.")
while i < top:
print("At the top i is %d" % i)
numbers.append(i)
i += int(incrementor)
print(... | true |
52663217d0bd00aa1d193280e8511e0b0e9a9a52 | Monsieurvishal/Python-projects | /words_count_in_File/main.py | 1,301 | 4.21875 | 4 | import os
def countWords(fileName):
numwords = 0
numchars = 0
numlines = 0
with open(fileName, 'r') as file:
for line in file:
print(line)
wordlist = line.split() #Splits at space so we remain with only words
numlines += 1 #program iter
... | true |
e913907fe4d25cc15b28c6d3132e7d59bb8fc166 | whiteston/myplace | /CheckiO/CheckiO_Ele10.py | 814 | 4.40625 | 4 | """
Split the string into pairs of two characters.
If the string contains an odd number of characters,
then the missing second character of the final pair should be replaced with an underscore ('_').
Input: A string.
Output: An iterable of strings.
Example:
split_pairs('abcd') == ['ab', 'cd']
split_pairs('abc') == ... | true |
fb7c7e699c07df03ac74b53eb65de1d0b5a6ebce | whiteston/myplace | /CheckiO/Ck_O'reilly02.py | 871 | 4.5625 | 5 | """
We have a List of booleans. Let's check if the majority of elements are true.
Some cases worth mentioning: 1) an empty list should return false; 2) if trues and falses have an equal amount, function should return false.
Input : A List of booleans.
Output : A Boolean.
Example:
is_majority([True, True, False, True... | true |
24219970550e3cba2aa8ed64571fc0877bddd4b9 | whiteston/myplace | /CheckiO/Ck_O'reilly04.py | 2,214 | 4.5625 | 5 | """
The first mission is quite simple. There is a light bulb, which by default is off, and a button, by pressing which the light bulb switches its state.
This means that if the light bulb is off and the button is pressed, the light turns on, and if you press it again, it turns off.
The function input is an array of d... | true |
d40ef59430f76031aa8d0aac866afa5dda709065 | nyladigm/practice-python | /character_input.py | 624 | 4.21875 | 4 |
'''
Exercise 1 from Practice Python.
Create a program that asks the user to enter their name and their age.
Print out a message addressed to them that tells them the year that they will turn 100 years old.
'''
import datetime
'''
ask for the users' name and age:
'''
your_name = input('What is your name: ')
user_age... | true |
6640cb67d2b41223b24f65b8b3d543bd45ac50cd | nyladigm/practice-python | /list_less_than_ten.py | 337 | 4.28125 | 4 | '''
Exercise 3: List Less Than Ten from Practice Python.
Take a list, say for example this one:
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
and write a program that prints out all the elements of the list that are less than 5.
'''
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
for numbers in a:
if numbers < 5:
... | true |
55288f853b23cd2042defb253ea5833db9fc24ee | codemonztah/ISBN-converter | /isbn.py | 1,646 | 4.125 | 4 | #Application to convert a Product ID to a standard ISBN-10 Number
#Function to detect only numbers are entered by the users
def allowedNumber(ID):
for char in productID:
if not char in '1234567890.':
return print("These arent numbers")
return True
#Start of main program
userInput=input(... | true |
64fe2e3678671bffb1b6ccf3a9af5435ff4f6f3b | isaza00/holbertonschool-higher_level_programming | /0x0B-python-input_output/4-append_write.py | 557 | 4.3125 | 4 | #!/usr/bin/python3
"""
function that appends a string at the end of a
text file (UTF8) and returns the number of characters added:
Prototype: def append_write(filename="", text=""):
If the file doesn’t exist, it should be created
You must use the with statement
You don’t need to manage file per... | true |
e2f387cf76d36f6d0d05eef27f3b3038f8f7d6ed | adnansadar/Python-programs | /snakify-programs/Sets/colorCubes.py | 1,332 | 4.21875 | 4 | # #Alice and Bob like to play with colored cubes. Each child has its own set of cubes and each cube has a distinct color, but they want to know how many unique colors exist if they combine their block sets.
#To determine this, the kids enumerated each distinct color with a random number from 0 to 108. At this point the... | true |
9a41a2085a89881935e92d7e7affdb01f05e815c | adnansadar/Python-programs | /HackerRank/mutations.py | 623 | 4.25 | 4 | #Read a given string, change the character at a given index and then print the modified string.
# Input Format
# The first line contains a string,
# .
# The next line contains an integer , denoting the index location and a character
# separated by a space.
# Output Format
# Using any of the methods explained above, ... | true |
a7213446084d2e66f560f39b18afe575a1993574 | adnansadar/Python-programs | /HackerRank/second_lowest.py | 1,081 | 4.40625 | 4 | # Given the names and grades for each student in a Physics class of
# students, store them in a nested list and print the name(s) of any student(s) having the second lowest grade.
# Note: If there are multiple students with the same grade, order their names alphabetically and print each name on a new line.
# Input For... | true |
930fb96a97c27b79e3db16f3f8c2326a8588c105 | M1ky/Coder-Byte-Challenges | /palindrome_two.py | 928 | 4.34375 | 4 | '''
Have the function PalindromeTwo(str) take the str parameter being passed and return the string true if the parameter is a palindrome,
(the string is the same forward as it is backward) otherwise return the string false. The parameter entered may have punctuation
and symbols but they should not affect whether th... | true |
65a0da474d146eebbeb639e233187e7eaba86506 | M1ky/Coder-Byte-Challenges | /counting_minutes.py | 890 | 4.3125 | 4 | '''
Have the function CountingMinutesI(str) take the str parameter being passed which will be two times
(each properly formatted with a colon and am or pm) separated by a hyphen and return the total number of minutes between the two times.
The time will be in a 12 hour clock format. For example: if str is 9:00am-1... | true |
5c15ff81115a8ba8aece6da08e2e0691439dea66 | rashmitha-prabhu/Python | /NATO/main.py | 427 | 4.21875 | 4 | import pandas
data = pandas.read_csv("nato_phonetic_alphabet.csv")
nato_phonetic = {rows.letter: rows.code for (index, rows) in data.iterrows()}
def get_name():
name = input("Enter a word : ").upper()
try:
phonetic = [nato_phonetic[letter] for letter in name]
except KeyError:
print("Sorry... | true |
4f4ab1c109af094befd8913718985f3da4632dd1 | arturaszuta/python_bootcamp | /strings.py | 499 | 4.15625 | 4 | print('This is a string! {}'.format('This is something Ive inserted!'));
print('The {2} {1} {0}'.format('one', 'two', 'three'));
print('The {a} {b} {c}'.format(a='one', b='two', c='three'));
result = 100 / 7777;
# float : {value:width:precision}
print(result);
print('The result was {r:1.3f}'.format(r=result));
prin... | true |
306a520c493551908da0fe71355bdf3d31a5ca3b | drh89/PythonKursus | /phonenumber_check.py | 1,351 | 4.125 | 4 | #This program checks wether a string (arg) is an american phonenumber.
## def isPhoneNumber(text):
## if len(text) != 12:
## return False #not phone number sized
## for i in range(0,3):
## if not text[i].isdecimal():
## return False #No area code
## if text[3] != '-':
## return... | true |
146c08343ca5a10bfc2e43d700cfc364e242383a | bhatsom/Python-Lang-Master | /language-fundamentals/collection-types/workingWithSet.py | 2,709 | 4.3125 | 4 | # https://www.techbeamers.com/python-set/
my_set_1 = {} # will create dictionary
print('type(my_set_1)): ', type(my_set_1))
my_set_2 = set() # will create empty set
print('type(my_set_2)): ', type(my_set_2))
my_set = {7, 8}
try:
print(my_set[0]) # set does not support index based access
except Exception as ex:
... | true |
8a4174280a5ee4ca76e08ae31f752ba7b991a0f2 | brittany-fisher21/python2 | /sum2.py | 232 | 4.34375 | 4 | list_of_numbers = [2, 10, 8, 3]
largest = 0
for number in list_of_numbers:
if number > largest:
largest = number
print("The current number is:" + str(number))
print("The current largest number is:" + str(largest)) | true |
20ece7904dfa101e7e20b19653db8a67a1323cf5 | Ian0813/Using_Python_to_Interact_with_the_Operating_System | /Week3/split_sample.py | 226 | 4.40625 | 4 | #!/usr/bin/python3
import re
# the first parameter is a regular expression pattern, the front of word r represent that is a raw string.
result = re.split(r"the|a", "One sentence. Another one? And the last one!")
print(result)
| true |
1871f6d9e78108972a9caa339603f8ceb2426a2a | premdhanawade/Marvellous | /Assignment 1/Assignment1_8.py | 330 | 4.125 | 4 | #Write a program which accept number from user and print that number of “*” on screen.
#---------------------------------------------------------------------------------------
def printPattern(x):
for i in range(x):
print("*",end=" ")
x=(int(input("Enter the number")))
printPatt... | true |
95dfb0579f650cd22c5a0543e8677f76b22a3c78 | premdhanawade/Marvellous | /Assignment 3/Assignment3_2.py | 484 | 4.21875 | 4 | #Write a program which accept N numbers from user and store it into List. Return Maximum
#number from that List.
#Input : Number of elements : 7
#Input Elements : 13 5 45 7 4 56 34
#Output : 56
if __name__ == '__main__':
x = int(input("Enter number of elements: "))
list = []
max=0
for i in ra... | true |
96dac6db5ef61e8c6a128af54a4bf132e64de80a | byorumus/algoritmalar | /question1.py | 495 | 4.25 | 4 | def is_greater_than(a, b):
"""
This function compares two given integers, returning True if first is greater.
:param a: Integer
:param b: Integer
:return: Boolean
"""
if is_negative(a) and is_negative(b) and a//b==0:
return True
elif a // b == 0:
return False
elif a ... | true |
f9d235369c80dfb9fc1792d54f041bf42cf560f9 | knyga/robot-navigation | /robot_navigation.py | 2,191 | 4.25 | 4 | # to run this module from command line typing
#
# > python robot_navigation.py robot_data.json
#
# it reads the starting and the finishing points as well as
# the list of obstacles from robot_data.json file and then
# runs find_path() function that has to return the path
#
import sys
import numpy as np
import jso... | true |
303d1b1b98c9d289a9e2bf0e14b2c268ce2a1750 | Jeffzieee/MCap | /Data_Structures.py | 338 | 4.40625 | 4 | # Assigning List Element as value of List.
List = ['Physics', 'chemistry', 2001, 2000]
List.append(2054)
print(List)
#Accessing Elemennts from a Tuple
tuple = ('Python', 'Java', 'C')
print(tuple[1])
#deleting dictionary elements
dict = {
1 : 'Physics',
2 : 'Chemistry',
3 : 'Maths'
}
del di... | true |
9cee33b59045fa697027b1121c554f53858a2eee | sirinenisaikiran/Python | /Practice/pynative.com/Basic Exercise for Beginners/09ReverseOfANumber.py | 862 | 4.15625 | 4 | # Question 9: Reverse a given number and return true if it is the same as the original number
# Expected Output:
# original number 121
# The original and reverse number is the same: True
# original number 125
# The original and reverse number is the same: False
# True
number = input("Enter the number: ")
number = st... | true |
8ebb7fcabc76b7f4249bbbbbed6d3cf74f13e36e | vkhrbanda97/python-3 | /factorial.py | 318 | 4.3125 | 4 | print("To print the Factorial of a number ")
print("")
f=1
num=int(input("Enter the number :"))
if num<0:
print("The factorial of negative number does not exist!!!")
elif num==0:
print("The factorial of 0 is always 1")
else:
while num>0:
f=num*f
num-=1
print("The factorial is",f) | true |
8f40eb309f78f51c97c8d4bb25fd88a6c4845fb6 | acarmonabelmonte/CFGS_Desarrollo_Aplicaciones_Web_DUAL | /programacion/python/Ejercicios CodeWars/Numerical Palindrome .py | 798 | 4.25 | 4 | #A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward.
#Examples of numerical palindromes are:
#2332
#110011
#54322345
#For a given number num, write a function to test if it's a numerical palindrome or not and return a boolean (true if it is and false if n... | true |
0ae0bcd7d60ff62dea258f4357d8f3d4c41ca61e | pk8742/Python-Projects | /Acronym.py | 245 | 4.375 | 4 | '''
You need to write a python script that generates an acronym word from a given sentence.
'''
text = str(input("Enter a String\n"))
text = text.split()
acronym = ""
for i in text:
acronym = acronym+str(i[0]).upper()
print(acronym) | true |
aac07f0be42169a641c89b861a12f340dad808a3 | pk8742/Python-Projects | /Adventure_Game.py | 632 | 4.1875 | 4 | '''
Write a fun Python script that takes the user on a fun adventure by choosing different options for the path.
'''
name = str(input("Enter Your Name\n"))
print(f"{name} you are stuck in a forest. Your task is to get out from the forest without dieing")
print("You are walking threw forest and suddenly a wolf come... | true |
312885dded5cb35e15b0b15a85d94f279e0368f5 | mujeebishaque/AutomateTheBoringStuffWithPython | /dict.py | 768 | 4.3125 | 4 | # syntax
dict = {'dude':'black', 'key': 'value'}
# syntax for ints as key
another_dict = {12:'some_value', 0: 'zero', 2: 'two'}
# print(another_dict[0])
# Dicts are un-ordered means
first = {'name': 'doodoo', 'gender': 'male'}
# second = {'gender':'male', 'name':'doodoo'}
# print(first == second) => returns true
# ch... | true |
c8c91dd18c598a8d4fbda2a8daf4c88cdbbe2db8 | ajanraj/Nptel-Python-2019 | /Week_5_ProgrammingAssignment-3_Semi Primes.py | 1,276 | 4.28125 | 4 | # A semiprime number is an integer which can be expressed as a product of two distinct primes. For example 15 = 3*5 is a semiprime number but 9 = 3*3 is not .
# Given an integer number N, find whether it can be expressed as a sum of two semi-primes or not (not necessarily distinct).
# Input Format:
# The first line co... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.