blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
7a1cdf1af372986d74d8b8d7c5da1db0d4cbf231 | annikathiele/mappython | /map.py | 1,168 | 4.125 | 4 | import time
def sort_a(word_list):
"""
Recursive implementation of quick- or mergesort.
Parameter
---------
word_list : list of str
list to be sorted
Returns
-------
int
sum of all swaps and comparisons
float
time used in ms
"""
# return mergesort_or_quicksor... | true |
f7fbaf7d026ece3fcf32abe32aaa86e38ea9ef62 | PQCuongCA18A1A/Ph-m-Qu-c-C-ng_CA18A1A | /PhamQuocCuong_44728_CH04/Exercise/page_109_exercise_03.py | 680 | 4.125 | 4 | """
Author: Phạm Quốc Cường
Date: 22/9/2021
Problem:
You are given a string that was encoded by a Caesar cipher with an unknown distance value. The text can contain any of the printable ASCII
characters. Suggest an algorithm for cracking this code
Solution:
"""
def decoded(s):
for i in ra... | true |
574990b7a33979586402dbb0c7c1add1d3f777a8 | PQCuongCA18A1A/Ph-m-Qu-c-C-ng_CA18A1A | /PhamQuocCuong_44728_CH03/Exercise/page_85_exercise_03.py | 277 | 4.28125 | 4 | """
Author: Phạm Quốc Cường
Date: 8/9/2021
Problem:
Write a loop that counts the number of space characters in a string. Recall that the space character is represented as ' '.
Solution:
"""
a=input("How to use a for loop in Python")
for i in a:
print(i.count(' ') + 1)
| true |
c77c3dff6b5509d49e04e6b59f780e740a1ee0a9 | kushckwl/python_project | /guess_number.py | 484 | 4.125 | 4 | import random
def guess(x):
random_number = random.randint(1, x)
guess = 0
while guess != random_number:
guess = int(input(f"Guess a number between 1 and {x}:"))
if guess < random_number:
print('Sorry , again guess, too low')
elif guess > random_number:
prin... | true |
b8221fd9e4d6c21951d3db47378cbb240709bd46 | anselmos/coding-problem | /solutions/2019_10_29.py | 1,210 | 4.125 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2019 [Anselmos](github.com/anselmos) <anselmos@users.noreply.github.com>
#
# Distributed under terms of the MIT license.
"""
Given a list of numbers and a number k, return whether any two numbers from the list add up to k.abs
For example,... | true |
d6331e71856771b33e5d69ddaf18b10ee03be5a6 | ThomsonTang/python-tutorials | /python-cookbook/src/data-structures-algorithms/1-3-kepping-last-items.py | 1,477 | 4.46875 | 4 | """1.3 Keeping the last N items
The following code performs a simple text match on a sequence of lines and yields the matching line along with the
previous N lines of context when found.
When writing code to search for items, it is common to use a generator function involving yield, as shown in this
recipe's solutio... | true |
aa6c4f363adbf3ed4e9d11cd8d36fa413d30d599 | one-last-time/python | /controlFlow/ConditionalStatement.py | 1,995 | 4.4375 | 4 | # '''
# You decide you want to play a game where you are hiding
# a number from someone. Store this number in a variable
# called 'answer'. Another user provides a number called
# 'guess'. By comparing guess to answer, you inform the user
# if their guess is too high or too low.
# Fill in the conditionals below t... | true |
283667a72bf6107d54cf1f6f1c09af1577b2f9e7 | one-last-time/python | /functions/function.py | 746 | 4.125 | 4 | #Write a function named population_density that takes two arguments, population and land_area, and returns
#a population density calculated from those values. I've included two test cases that you can use to verify
#that your function works correctly. Once you've written your function, use the Test Run button to test ... | true |
01aa1b0165b4533b6869071f5885fd4874bc9392 | one-last-time/python | /list.py | 392 | 4.34375 | 4 | animal=["tiger","lion","dog","cat"]
#shows full list
print(animal)
#get size
print(len(animal))
#show an element
print(animal[0])
#show an element from last
print(animal[-4])
print(animal[-3])
#delete an element in list
del animal[2]
print(animal)
#sort
animal.sort()
print(animal)
#sort
animal.so... | true |
165662dd2df0759cb43172f690558cdd2b62e9cc | one-last-time/python | /Data Types and Operators/ArithmeticOperators.py | 665 | 4.1875 | 4 | #addtion,subtraction,multiplication,division,mod are same as other language
print(((1+2+3)*(4/2)-5)%3)
#power
#get 2^3
print(2**3)
#integer divison
#it rounds the result
print(8//3)
print(-8//3)
"""
Quiz: Calculate
In this quiz you're going to do some calculations for a tiler. Two parts of a floor need tiling. ... | true |
46ca34ac7cff4689deb3f0acbede5503534c2ca6 | FinchyG/Python_testing_fridge_temperatures | /Testing_fridge_temperatures.py | 920 | 4.28125 | 4 | # Test whether fridge temperatures are between 1 and 5 degrees Celsius
# function with one parameter, temperatures: a list of numbers
def test_temperature(temperatures):
# initialise empty list to store temperatures outside of range 1 to 5
unacceptable_temperatures = []
# iterate through input list
... | true |
c7f864ea1b3915f64b2b083754ef288b7214c329 | DeepankJain/Python-Programs | /Prog17.py | 430 | 4.1875 | 4 | #Python function to check whther a string is palindrome or not
str = input("Enter any string: ")
def checkPalindrome(teststring):
i = 0
j = len(teststring)-1
while i < j:
if teststring[i] != teststring[j]:
print("Not a palindrome")
break
else:
i ... | false |
b9dac96e603a2af6b4db973904175d7e808dc9c8 | DeepankJain/Python-Programs | /Prog3.py | 238 | 4.3125 | 4 | #To check whether a number is postive, negative or Zero
num1 = int(input("Enter any number:"))
if num1 > 0:
print("Number is positive")
elif num1 == 0:
print("Number entered is Zero")
else:
print("Number is negative")
| true |
42838d219ffd6d447c796649fe4cc9579a1348d4 | raezir/The-Hoodrat-Repository | /test1.py | 551 | 4.125 | 4 | #!/usr/bin/env python
#import sys
'''
Created on Jan 28, 2017
This code opens a text file and reads it, saving it to line and then printing it.
@author: rkbergsma
'''
f = open('Article1.txt','r') #open to read
line = f.readlines() #reads all lines in file
#line = [x.strip() for x in line... | true |
fc36149cf8ad326668e5aba6ddc55bc2e135a5b0 | theLAZYmd/challenges | /easy/leapyears.py | 930 | 4.21875 | 4 | # https://www.hackerrank.com/challenges/write-a-function/problem
import datetime
def is_leap(year):
return (1900 <= year <= 10 ** 5) and ((year % 4 == 0 and year % 100 != 0) or (year % 400 == 0))
now = datetime.datetime.now()
for i in range(now.year): #all years up to present year
if is_leap(i): ... | false |
296e3317f545906b0194e5e049a35dda9fb16ae9 | graysonjclark1/comp110-21f-workspace | /exercises/ex01/relational_operators.py | 572 | 4.125 | 4 | """Input 2 variables and demonstrate how relational operators work."""
__author__ = "730481947"
left: int = int(input("Left-hand variable: "))
right: int = int(input("Right-hand variable: "))
result_1: bool = left < right
print(str(left) + " < " + str(right) + " is " + str(result_1))
result_2: bool = left >= right
pri... | false |
08f6f7b1c7fa5c063ce5be8f1d8e7213ac9c7b01 | Melwyn12/Python-Projects | /simpleAdditionQuiz.py | 2,166 | 4.125 | 4 | # Math game quiz
# prompts users to answer simple addition problems using random numbers from 0-100
# added subtraction, multiplication, and division
def printBanner():
print("\t\t\t ##################### ")
print("\t\t\t Math Quiz ")
print("\t\t\t By Falconscrest123 ")
print("\t\t\t ###... | true |
e8f4e29b97a0adeca5cdccd8c33b4063cfa9b516 | teosss/HomeWorkPyCore | /lesson_6/task_1.py | 1,212 | 4.34375 | 4 | def func_1():
"""
Function 1 find the even, odd, div23 numers classic method """
even = []
odd = []
div23 = []
for i in range(1,10):
if i % 2 == 0:
even.append(i)
if i % 3 == 0:
odd.append(i)
if i % 2 != 0 and i % 3 != 0:
div23.append(... | false |
4c73f3903714e956a47065cfb51c2438159bcfa9 | teosss/HomeWorkPyCore | /lesson_8/task_1.py | 938 | 4.25 | 4 | import super_module_t1
def input_area(value):
""""
This function determines the type of figure
Input:
value(str)
Result:
(int,float)
""""
if value is '1':
s = int(input("Enter first side: "))
b = int(input("Enter second side: "))
return super_module_t1.... | true |
dae37bc59b17b2e7e9b6118b19a3bcac1fadc43b | Panic-point1/Algorithmia | /python/binary_search.py | 857 | 4.25 | 4 | '''
In binary search,
- Compare x with the middle element.
- If x matches with the middle element, we return the mid index.
- Else if x is greater than the mid element, then x can only lie in the right (greater) half subarray after the mid element.
Then we apply the algorithm again for the right half.
- Else i... | true |
57ba2c2cfe3ab44fc716e148322c16268f2204a3 | JessicaJang/cracking | /Chapter 3/q_3_5.py | 1,185 | 4.15625 | 4 | # Chapter 3 Stacks and Queues
# 3.5 Sort Stack
# Write a program to sort a stack such that the smallest items are on the top
# You can use an additiona temporary stack, but you may not copy the elements
# into any other data structure (such as an array). The stack supports
# the following operations: push, pop, peek a... | true |
0e447a93b2db7926b93b73bad2ea46111e7a493e | JessicaJang/cracking | /Chapter 2/q_2_3.py | 453 | 4.28125 | 4 | # Chapter 2 Linked Lists
# Interview Questions 2.3
# Delete middle node:
# Implement an algorithm to delete a node in the middle
import os
from LinkedList import LinkedList
from LinkedList import LinkedListNode
def delete_middle_node(node):
node.value = node.next.value
node.next = node.next.next
ll = LinkedList()
... | true |
9baa2091eff6073b7f0642899a0ee3f07fbf96c0 | Cosmo767/Practice | /Udemy_Python_refresher/review_2_getting_input.py | 304 | 4.1875 | 4 | # name = input("Enter your name: ")
# print(name)
# input gives you a string, not a number
size_input = input("How big your house in sq feet?:" )
square_feet = int(size_input)
sqr_meters = square_feet /10.8
string = f"{square_feet} square feet is equal to {sqr_meters:.2f} square meters"
print(string) | true |
1114f176bb5c3b78c22c54aad4c61f258b5a1579 | Cosmo767/Practice | /jason_algos_one/most_common_letter.py | 1,906 | 4.25 | 4 | def most_common_letter(text):
"""Returns the letter of the alphabet that occurs most frequently. If there is a tie, choose the letter that comes first in the alphabet.
If there are no letters, return the empty string"""
'''
create a dictionary with a value for each key that counts how many time
... | true |
0d4a3ed33566dd1980674c2ad18336f3c3b6b597 | Cosmo767/Practice | /Udemy_Python_refresher/33_unpacking_args.py | 748 | 4.28125 | 4 |
def add(*args):
total = 0
for arg in args:
total = total + arg
return total
def mutliphy(*args):
# print(args)
total = 1
for arg in args:
total = total*arg
return total
# print(mutliphy(1,3,5))
def apply(*args, operator): # creates a named operator at the end, must pass ... | true |
0906b7cc9dda5c140134c5a68fde84daa6453166 | 100sun/python_programming | /chp5_ex.py | 1,340 | 4.28125 | 4 | # 5.1 Capitalize the word starting with m:
song = """ When an eel grabs your arm, ... And it causes great harm, ... That's - a moray!"""
song = song.replace('m', ' M')
print(song)
# 5.2 Print each list question with its correctly matching answer in the form: Q: question A: answer > > >
questions = [
"We don't serve... | true |
c4f3dbc5ab71c5fb6c5f3bd36fcb0eb469d2f27b | ulillilu/MachineLearning-DeepLearning | /03-02.Database/sqlite3_test.py | 785 | 4.40625 | 4 | import sqlite3
# sqlite 데이터베이스 연결
dbpath = "test.sqlite"
conn = sqlite3.connect(dbpath)
# 테이블을 생성하고 데이터 넣기
cur = conn.cursor()
cur.executescript("""
/* items 테이블이 이미 있다면 제거하기 */
DROP TABLE IF EXISTS items;
/* 테이블 생성하기 */
CREATE TABLE items(
item_id INTEGER PRIMARY KEY,
name TEXT UNIQUE,
price INTEGER
);
/* ... | false |
41f2085568658b304f233161dceae20dfc7bf21d | zndemao/PythonStudy | /note19函数与过程.py | 937 | 4.21875 | 4 | # 函数 与 过程
# 函数:有返回值
# 过程:没有返回值
# Python只用函数没有过程
def hello():
print('hello world')
temp = hello()
print(type(temp))
# 有返回值,返回返回值,没有返回NoneType
def back():
return [1, 'love', 3.14]
print(back())
# 函数变量的作用域
def discounts(price, rate):
final_price = price * rate
# print(old_price)
old_price = 20... | false |
e5eccbc671e5225f8da0c3dbf9666ef6b81ec8c2 | tomasvalda/dt211-3-cloud | /Euler/solution7.py | 616 | 4.21875 | 4 | #!/usr/bin/python
def is_prime(num): # function for check if the number is prime, returns true or false
if num == 2:
return true
if num < 2:
return false
if not num & 1:
return false
# for x in range # number is prime when we can divide it only by the exact number or 1
#################
return true
def ... | true |
4189cbe031375dd974083eb6e006b04852b29392 | Snehal2605/Technical-Interview-Preparation | /ProblemSolving/450DSA/Python/src/string/MinimumSwapsForBracketBalancing.py | 1,674 | 4.3125 | 4 | """
@author Anirudh Sharma
You are given a string S of 2N characters consisting of N ‘[‘ brackets and N ‘]’ brackets.
A string is considered balanced if it can be represented in the for S2[S1] where S1 and S2
are balanced strings.
We can make an unbalanced string balanced by swapping adjacent characters.
Calculate ... | true |
3ea12eeb1275db5ca2a730ad5cd55e8f9da5e755 | Snehal2605/Technical-Interview-Preparation | /ProblemSolving/450DSA/Python/src/binarytree/LevelOrderTraversal.py | 1,314 | 4.21875 | 4 | """
@author Anirudh Sharma
Given a binary tree, find its level order traversal.
Level order traversal of a tree is breadth-first traversal for the tree.
Constraints:
1 <= Number of nodes<= 10^4
1 <= Data of a node <= 10^4
"""
def levelOrderTraversal(root):
# Special case
if root is None:
return None... | true |
355c5ba49e9a5ee0d5862f1155800456b10fdb6c | Snehal2605/Technical-Interview-Preparation | /ProblemSolving/450DSA/Python/src/dynamicprogramming/MobileNumericKeypad.py | 1,471 | 4.28125 | 4 | """
@author Anirudh Sharma
Given the mobile numeric keypad. You can only press buttons that are up, left, right, or down to
the current button.
You are not allowed to press bottom row corner buttons (i.e.and # ).
Given a number N, the task is to find out the number of possible numbers of the given length.
"""
def ge... | true |
a0faf6dc0aaddd8e0cfbf57ff9ed2a53b47a380c | Snehal2605/Technical-Interview-Preparation | /ProblemSolving/450DSA/Python/src/dynamicprogramming/LongestIncreasingSubsequence.py | 1,346 | 4.125 | 4 | """
@author Anirudh Sharma
Given an integer array nums, return the length of the longest strictly increasing subsequence.
A subsequence is a sequence that can be derived from an array by deleting some or no elements
without changing the order of the remaining elements. For example, [3,6,2,7] is a subsequence
of the... | true |
e7d9e7d85e9e3912415fb2947c392157ab7414e3 | mdcowan/SSL | /Lecture_Files/Wk1_2/python.py | 722 | 4.375 | 4 | # To get user input, you must first import system functionality
import sys
# You can then use 'raw user input' to get data from the user
name = raw_input("What is your name?")
# From there you can use the variable with the user input data
# Writing to a file
# a = append, w = overwrite
# Template to open a file to wr... | true |
185a1af3665c4fdc6582968114478154861e6789 | kaory-china/python | /CC1_2 Week/square_area_perimeter.py | 303 | 4.34375 | 4 | 'it calculates square perimeter and area based on user int input of the square side size'
MedidaLadoQuadrado = int(input("Digite o valor correspondente ao lado de um quadrado:"))
Perimetro = MedidaLadoQuadrado * 4
Area = MedidaLadoQuadrado ** 2
print("perímetro:", Perimetro,"-","área:", Area)
| false |
c6a687f92ae05d2411702febf255dd02ca34d561 | ishitach/AI-and-PyTorch | /Neural network using relu.py | 714 | 4.15625 | 4 | #Creating a neural network with 128,64 hidden layers and 10 output layers and ReLU activation
import torch.nn.functional as F
class Network(nn.Module):
def __init__(self):
super().__init__()
# Inputs to hidden layer linear transformation
self.hidden1 = nn.Linear(784, 128)
self.hidd... | true |
0a61e216e7bbade2dd5090e75285384bc92159f3 | clagunag/Astr-119 | /HW_1_1.py | 489 | 4.1875 | 4 | # -*- coding: utf-8 -*-
'''
Cesar Laguna
Python 3.6.1
'''
import numpy as np
'''
# 1
Takes inputs (b, c) and provides output of A (area of a rectangle)
Rectangle = rec
'''
b = int(input('Base (rec) :')) #input allows for user to input their own data/ numbers
c = int(input('Height (rec) :'))
A_rec = b*c
print ('Area o... | true |
f33007c902b9ffd40cf7bf86d2f53895fbca3aec | ricardoquijas290582/PythonCourse | /metodos_listas.py | 1,668 | 4.375 | 4 | #metodos de listas
lista = ["Juan", "Luis", "Pedro"]
print(lista)
print("-----------")
#nos regresa el indice del elemento que queremos buscar en una lista, si es que existe
luis_index = lista.index("Luis") #1
print(luis_index)
print("-----------------")
#agregar un elemento al final de la lista
lista.append("Pablit... | false |
b84e10fbca2bba78cad0cd936f4902e5cd06af8d | Data-Winnower/Python-Class-Projects | /Turtle Star Drawing.py | 2,866 | 4.40625 | 4 | # Kale Perry
# Programming Concepts and Applications
# CSC1570-4914 Fall 2020
# 01 October 2020
# Repeating Turtle
# Repeating Turtle
# Repeating Turtle
# Did I remember to say, Repeating Turtle?
import turtle
turtle.speed(5)
again = "Yes"
print ("LET'S DRAW A STAR!")
while again =="Yes" or again == "Y" o... | true |
0276d2004f3ec6f8ac3fa40257e53460485caf46 | RaspiKidd/PythonByExample | /Challenge44.py | 542 | 4.28125 | 4 | # Python By Example Book
# Challenge 044 - Ask how many people the user wants to invite to a party. If they enter a number below 10.
# ask for the names and after each name display "(name) has to be invited to the party". If they enter a number which is
# 10 or higher display the message "Too many people".
invite = in... | true |
75ba36c9c802dfbdb8f96e10a7a417a6f99c338e | RaspiKidd/PythonByExample | /Challenge72.py | 448 | 4.5 | 4 | # Python By Example Book
# Challenge 072 - Create a list of six school subjects. Ask the user which of these subjects they
# don't like. Delete the subject they have chosen from the list before you display the list again.
subjects = ["maths", "english", "p.e", "computing", "science", "history"]
print (subjects)
print ... | true |
4a139d8ec093a78e7f7dad5bc47fbd67c4edc808 | RaspiKidd/PythonByExample | /Challenge92.py | 615 | 4.28125 | 4 | # Python By Example Book
# Challenge 092 - Create two arrays (one containing three numbers that the user enters and
# one containing a set of five random numbers). Join these two arrays together into one large array.
# Sort this large array and display it so that each number appears on a seperate line.
from array impo... | true |
2113eeb68b5b660c78d568123082b411750f3a4a | RaspiKidd/PythonByExample | /Challenge54.py | 552 | 4.4375 | 4 | # Python By Example Book
# Challenge 054 - Randomly chose heads or tails ("h" or "t"). Ask the user to make their choice.
# If their choice is the same as the randomly selected value, display the message "You win",
# otherwise display "bad luck". At the end, tell the user if the computer selected heads or tails.
impor... | true |
40c6fccf41c2424e1d787d59e3c42bf8724004d0 | RaspiKidd/PythonByExample | /Challenge87.py | 402 | 4.4375 | 4 | # Python By Example Book
# Challenge 087 - Ask the user to type in a word and then display it backwards on seperate lines.
# For instance, if they type in "Hello" it should display as shown below:
'''
Enter a word: Hello
o
l
l
e
H
'''
word = input("Enter a word: ")
length = len(word)
num = 1
for x in word:
positi... | true |
a4264a9c28edd71030c523ff9f18de6f01e76e38 | RaspiKidd/PythonByExample | /Challenge83.py | 462 | 4.375 | 4 | # Python By Example Book
# Challenge 083 - Ask the user to type a word in uppercase. If they type it in lowercase, ask them to try again.
# Keep repeating this until they type in a message all in uppercase.
msg = input("Enter a message in uppercase: ")
tryAgain = False
while tryAgain == False:
if msg.isupper():
... | true |
ab858ab774b8f552cd18e61d31dae22f7d2de6b0 | RaspiKidd/PythonByExample | /Challenge17.py | 574 | 4.21875 | 4 | # Python By Example Book
# Challenge 017 - Ask the users age. If they are 18 or over , display the message "You can vote", if they are aged 17, display the
# message "You can learn to drive", if they are 16 , display the message "You can buy a lottery ticket", if they are under 16, display
# the message "You can go tri... | true |
663de86686531f0522892249b03b0169d46cdb62 | gomsvicky/PythonAssignmentCaseStudy1 | /Program13.py | 318 | 4.28125 | 4 | list1 = []
num = input("Enter number of elements in list: ")
num = int(num)
for i in range(1, num + 1):
ele = input("Enter elements: ")
list1.append(ele)
print("Entered elements ", list1)
max1 = list1[0]
for x in list1:
if x > max1:
max1 = x
print("Biggest number is ", max1)
| true |
a3c327eacdfddf49ddaaff474414f2eaffae397c | brittany-morris/Bootcamp-Python-and-Bash-Scripts | /python/learndotlab/evenorodd.py | 272 | 4.15625 | 4 | #!/usr/bin/env python3
import sys
list = sys.argv[1]
with open(list, 'r') as f:
for num in f:
num = num.strip()
value = int(num)
if value % 2 == 0:
print(num, True)
# True means number is Even
else:
print(num, False)
# False means number is Odd
| true |
bfa6ad316c5a87c2b3c724ed7e1129c01e0a193f | Sam-stiner/science-fairproject | /science fair.py | 1,697 | 4.15625 | 4 | def convertString(str):
try:
returnValue = int(str)
except ValueError:
returnValue = float(str)
return returnValue
print 'welcome to satilite tracker 0.2.1'
print 'what object would you like find the orbit around?'
print ' 1: earth'
print ' 2: the sun'
print ' 3: a custom ... | true |
40e018205dbc3671f3751ab5d0f359282f3150a4 | DivyangPDev/automate-Boring-Stuff-With-Python | /Chapter 6/Chapter_6.py | 2,374 | 4.1875 | 4 | #! /usr/bin/env python3
#Practice Questions
# 1. What are escape characters?
# Escape characters lets you use characters that otherwise impossible to put into a string. An escape character
# consists of a backslash (\n) followed by the character you want to add to the string
# 2. What do the \n and \t escape characte... | true |
1bfb612ed8408426e7cc5c6a28ad3393e797844d | ardenercelik/Python | /convert_to_alt_caps.py | 1,093 | 4.40625 | 4 | """
Write a function named convert_to_alt_caps that accepts a string as a parameter and returns a version of the
string where alternating letters are uppercase and lowercase, starting with the first letter in lowercase.
For example, the call of convert_to_alt_caps("Pikachu") should return "pIkAcHu".
"""
def conver... | true |
5ae848cedbd3dd5b0cc94f0404dd7e9daf40b638 | Bashir63/pands | /code/Week02/bmi.py | 454 | 4.28125 | 4 | # This is my first weekly problem solving program for this course
# This program calculates the user's BMI using their inputs
# Author : Bashir Ahammed
# inputs for user's height and weight
weight = float (input ("Enter weight: "))
height = float (input ("Enter height: "))
# Conversion of centimeters to meter squa... | true |
a6589717a9591f153892ead3989283aa4e676401 | PriyankaSahu1/Practise-Python | /handson/handson15.py | 409 | 4.125 | 4 | #handson 15
list=["abc","bcd","jkl","xyz","mno"]
#using membership operator
if("abc" in list):
print("abc is available")
else:
print("abc is not present")
#without using membership operator
for i in range(5):
if(list[i]=="abc"):
print("available")
break
else:
p... | true |
2d0d8ff19d55b823a7fbc84a7276da650f24f1a9 | Spekks/python-SEAS-Ejercicios | /Ejercicios/Unidad 3/Caso/UD03_EG1.py | 1,838 | 4.15625 | 4 | # Ejercicio guiado 1. Unidad 3
# a) Escribir algo parecido a un menú para elegir una entre varias opciones. Última línea muestra el resultado:
letter = input("Escriba la letra 'a', 'b' o 'c': ")
if letter == 'a':
print("Opción a")
elif letter == 'b':
print("Opción b")
elif letter == 'c':
print("Opción c"... | false |
f3eefe168776c1173fe236992812a1736c9464fd | Spekks/python-SEAS-Ejercicios | /Ejercicios/Unidad 4/Caso/UD04_EG1.py | 2,129 | 4.28125 | 4 | # Ejercicio guiado. Unidad 4.
# a) Vamos a dibujar cuadrados rellenos utilizando el carácter car que se pasará como argumento. Se pasan también el
# desplazamiento de cada línea (valor de a) y el número de caracteres que se escriben (valor de b) que es igual al
# número de líneas que se escriben. Todos ellos son d... | false |
baea71029f36481b204178ffded7ddf70da664d5 | treedbox/python-3-basic-exercises | /list/multi-dimensional/app.py | 375 | 4.40625 | 4 | # list two-dimensional
# list inside the list
foo = [[5, 6], [6, 7], [7, 2], [8, 4]]
print(foo)
# [[5, 6], [6, 7], [7, 2], [8, 4]]
# list multi-dimensional
# list inside the list inside the list
bar = [[5, 6], [6, 7], [7, [2, 6]], [[8, 5], 4]]
print(bar)
# [[5, 6], [6, 7], [7, [2, 6]], [[8, 5], 4]]
print(bar[0])
#... | false |
d425842338650746eb7de3fc1a2ad7d922c0deaa | stellakaniaru/simple-python-games | /tictactoe.py | 1,375 | 4.125 | 4 | '''
Tic Tac Toe game.
'''
import random
def drawBoard(board):
# This function prints out the board that it was passed.
# "board" is a list of 10 strings representing the board (ignore index 0)
print(' | |')
print(' ' + board[7] + ' | ' + board[8] + ' | ' + board[9])
print(' | |')
print('-----------')
pri... | true |
3821a69333bbbe017c04c25f68df88c3b3c61706 | ramesh1990/Python | /Easy/stock.py | 894 | 4.28125 | 4 | '''
Stock Buy Sell to Maximize Profit
The cost of a stock on each day is given in an array, find the max profit that you can make by buying and selling in those days.
For example, if the given array is {100, 180, 260, 310, 40, 535, 695}, the maximum profit can earned by buying on day 0, selling on day 3.
Again buy on... | true |
aa9e99206b9458bbb76c6e2d557d63301e5662ce | lavenderLatte/python_practice | /word_autoCorrection/edit_distance.py | 2,024 | 4.28125 | 4 | """
Function to compute edit distance between two words.
Edit distance -- the minimum number of +, -, r operations that are needed to convert str2 to str1.
+, -, r are addition, subtraction and replacement.
For example:
str1 = "abc", str2 = "ac". edit distance is 1 --> addition of b str2.
str1 = "abc", str2 = "axc". ... | true |
c8acc4486cb24f3219cda93255d5c0a822483cf9 | GeburtstagsTorte/Homework | /Projects/Genetic Algorithm/Bubble Arena/Populations.py | 1,105 | 4.46875 | 4 | """
Step 1:
Initialize:
Create a population of N elements, each with randomly generated DNA (genes)
(drawing)
Step 2:
Selection:
Evaluate the fitness of each element of the population and create a pool (mating pool)
Step 3:
Reproduction:
a) Pick two parents with probability according to t... | true |
45b58f45a716e59aea24bf7b11b81b1815a408e9 | riadassir/MyFirstRepository | /ex_06_02.py | 973 | 4.5 | 4 | #############################################################
# Riad Assir - Coursera Python Data Strucutres Class - ex_06_02.py
# Dealing with Files
#############################################################
#FileHandle = open('mbox-short.txt')
FileName = input('Enter the file name: ')
try:
FileHandle = open(... | true |
92e6e640eca88f65c651ef4b156992b7fb8c52fb | dtauxe/hackcu-ad | /plot.py | 2,690 | 4.15625 | 4 | #!/bin/python
# From:
# https://stackoverflow.com/questions/6697259/interactive-matplotlib-plot-with-two-sliders
from numpy import pi, sin
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import Slider, Button, RadioButtons
import math
# Draw the plot
def do_plot(sigstr):
def signal(t):
... | true |
8bf9e58c2d775db3e3c77f7e852de92dc521be55 | jjennas/web-ohjelmointi | /assignment2/2.py | 621 | 4.21875 | 4 | import re, statistics
#function finds numbers in string
def finding_numbers(s):
return re.findall(r"-?\d+",s)
answer = input("Give integers, can be separated by any character")
if not answer:
print("Please input integers separated by any character")
else:
numbers = finding_numbers(answer)
# Tries to co... | true |
98eb13251a8780adc7acdb61c5db8fec32e1a741 | lw2533315/leetcode | /uniquePaths_test.py | 876 | 4.40625 | 4 | # A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
# The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
# How many possible unique paths are there?
... | true |
9346d7d92949c4037d1bf5a76b65b48b2a398276 | newmayor/pythonlearning | /selectionSort.py | 666 | 4.1875 | 4 | def selSort(L):
"""Assumes that L is a list of elements that can be compared using >.
Sorts L in ascending order. """
suffixStart = 0
while suffixStart != len(L):
#look at each element in suffix
for i in range(suffixStart, len(L)):
if L[i] < L[suffixStart]:
#... | true |
c947b7d0e412238a284ce7a8ca8515b77ff454a6 | newmayor/pythonlearning | /ex_IO.py | 2,724 | 4.1875 | 4 |
def print_numbers(numbers):
print("These are the currently stored phone numbers: ")
for k, v in numbers.items():
print("Name:", k, "\tNumber:", v)
print()
def add_number(numbers, name, number):
numbers[name] = number #use a dict to define name as the dict key and the associated number as the ... | true |
a4ce076b6389af67d906657b1653cdaad0e5996e | the-aerospace-corporation/ITU-Rpy | /tiler.py | 1,472 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Turns a rectangle into a number of square tiles.
Created on Thu Oct 15 17:24:31 2020
@author: MAW32652
"""
def tiler(m, n, dimList = []):
"""
Tiler outputs the size of the tiles (squares), that are required to fill
a rectangle of arbitrary dimension.
Note: It does ... | true |
a429f0cf76e5617d958e23514f1a4ba2d67d6e4f | rock-chock/leetcode | /412_fizzbuzz.py | 804 | 4.125 | 4 | """
https://leetcode.com/problems/fizz-buzz/
Write a program that outputs the string representation of numbers from 1 to n.
But for multiples of three it should output “Fizz” instead of the number and
for the multiples of five output “Buzz”. For numbers which are multiples of
both three and five output “FizzBuzz”.
"""
... | true |
e3551871af7f069111a413ee63db06796503aa90 | Tylerman90/PythonPractice | /odd_even_funk.py | 821 | 4.375 | 4 | #Write a program that reads a list of integers,
#and outputs whether the list contains
#all even numbers, odd numbers, or neither.
#The input begins with an integer
#indicating the number of integers that follow.
def user_values():
my_list = []
num_in_list = int(input())
for num in range(num_in_list):
... | true |
f145873536f4f3fcdec1bfc5fcc8cb065f5742f6 | kapiltiwari1411/python-lab | /kapil4reverse.py | 246 | 4.25 | 4 | #program to find reverse of enterd number.
num=int(input("please enter any number"))
reverse=0.
while(num>0):
reminder=num%10
reverse=(reverse*10)+reminder
num=num//10.
print(" reverse of the entered number\n", reverse)
| true |
651b8fba4e4f3bd3ee41aa4f4ee792988e3526ac | ArthurBrito1/MY-SCRIPTS-PYTHON | /Desafios/desafio37.py | 634 | 4.1875 | 4 | numero = int(input('Digite um numero inteiro qualquer:'))
print('''ESCOLHA UMA DAS BASES PARA CONVERSÃO:
[ 1 ] PARA CONVERTER PARA BINARIO:
[ 2 ] PARA CONVERTER PARA OCTAL:
[ 3 ] PARA CONVERTER PARA HEXADECIMAL:''')
opção = int(input('Sua opção: '))
if opção == 1:
print('{} convertido para binario é igual a ... | false |
60dd32a7b8c2906552b82b012c1e4e3a1914bbdd | ArthurBrito1/MY-SCRIPTS-PYTHON | /Exemplos/ex007.1aula.py | 355 | 4.1875 | 4 | nome = str(input('Qual é seu nome?'))
if nome == 'Arthur':
print('Que nome bonito!')
elif nome == 'Pedro' or nome == 'Maria' or nome == 'João':
print('Seu nome é bem popular no Brasil.')
elif nome in 'Ana Claudia Jessika Juliana':
print('Que belo nome feminino.')
else:
print('Seu nome é bem norm... | false |
a37d0bfdb5defc86998701657f9c11ff27113a1a | ItsPepperpot/hangman | /hangman.py | 2,362 | 4.125 | 4 | # Hangman.
# Made by Oliver Bevan in July 2019.
import random
print("Welcome to hangman!")
menu_choice = 0
while menu_choice != 3:
print("Please pick an option.")
print("1. Begin game")
print("2. Show rules")
print("3. Exit")
menu_choice = int(input())
if menu_choice == 1: # Begin game.
... | true |
cbd3e856cce1ba5c088408c9722989b82ee30709 | JamieBort/LearningDirectory | /Python/Courses/LearnToCodeInPython3ProgrammingBeginnerToAdvancedYourProgress/python_course/Section3ConditionalsLoopsFunctionsAndABitMore/22ExerciseLoops.py | 1,226 | 4.28125 | 4 | # First of two.
# Create a program that asks a user for 8 names of people.
# Store them in a list.
# When all the names have been given, pick a random one and print it.
# Second of two.
# Create a guess game with the names of colors.
# At each round pick a random color and let the user guess it.
# After a successful g... | true |
7096d9987e86cdc601fa4d2fbb6f748b69a4eb00 | Youngjun-Kim-02/ICS3U-Assignment2-python | /volume_of_cone.py | 726 | 4.40625 | 4 | #!/usr/bin/env python3
# Created by: Youngjun Kim
# Created on: April 2021
# This program calculates the volume of a cone
# with radius and height inputted from the user
import math
def main():
# this function calculates the volume of a cone
# main function
print("We will be calculating the area of ... | true |
e9ef8fd3021f0790cfd9d5b0895ac23f3aad980a | juanPabloCesarini/cursoPYTHON2021 | /Ejercicios Sección 4/Punto3.py | 362 | 4.375 | 4 | """
Escribir un programa que pregunte al usuario su edad y muestre por pantalla todos los años que ha cumplido (desde 1 hasta su edad).
"""
def pedirEdad():
return int(input("Tu edad: "))
def mostrarEdades(edad):
i=1
while i<=edad:
print("Tu edad es: ", i)
i+=1
def main():
edad = ped... | false |
6fcc046029e432c4919bb48b6005dfe3799068c3 | juanPabloCesarini/cursoPYTHON2021 | /Seccion 11/metodos_cadenas.py | 507 | 4.3125 | 4 | nombre = input("Ingresa tu nombre: ")
print("el nombre es: ", nombre.upper())
nombre = input("Ingresa tu nombre: ")
print("el nombre es: ", nombre.lower())
nombre = input("Ingresa tu nombre: ")
print("el nombre es: ", nombre.capitalize())
frase= input("Ingresa una frase: ")
letra= input("Letra a buscar: ")
prin... | false |
7bf07e28f7377b6b735b33f387d83f03b641b9db | ArmandoRuiz2019/Python | /Funciones/Funciones.txt | 1,789 | 4.1875 | 4 | Este mini proyecto te permitirá practicar un poco con funciones, listas, y la traducción de formulas matemáticas a sentencias de programación.
A fin de usar las notas en nuestro programa, necesitaremos que estén incluidas en un contenedor, específicamente una lista.
La rutina presenta los siguientes resultados a part... | false |
fc06cad0a5e98e8ea0acce7a20bf4e0725794df6 | ArmandoRuiz2019/Python | /Colecciones/Tuplas02.py | 1,028 | 4.125 | 4 | # -*- coding: utf-8 -*-
# Autor: Armando Ruiz
# Tuplas en Python
mi_tupla = (1,'Enmanuel')
print ('Mostrando un elemento de la tupla:',mi_tupla[1])
print ('Tupla:',mi_tupla)
# convierte una lista en tupla
# método list
mi_lista = list(mi_tupla)
print ('Tupla convertida en Lista:',mi_lista)
# convierte una tupla e... | false |
4b80e51dc0a98003cf82bc271886b0b61ff284e7 | sinugowde/PythonWorkSpace | /PP_006.py | 433 | 4.21875 | 4 | # PythonPractice_006: Polindrome
def checkPolindrome(stringVar):
for i in range(0, len(stringVar)//2):
if stringVar[i] != stringVar[-i-1]:
resVar = False
break
resVar = True
return resVar
# Main Function/Method
stringVar = input()
resVar = checkPolindrome(stringVar)
if resVar:
print("the Entered string... | true |
a2cbae5516ae86338884900c57ea0a60433b8260 | bradweeks7/CPE202 | /Labs/Lab1/lab1/lab1.py | 933 | 4.3125 | 4 |
def max_list_iter(int_list): # must use iteration not recursion
"""finds the max of a list of numbers and returns the value (not the index)
If int_list is empty, returns None. If list is None, raises ValueError"""
if int_list == None:
raise ValueError
# An empty list should return None
if len(... | true |
170f0f24b96c69417a0a2af693bdd53b7a00d88b | jeffersonsouza/computer-engineering-degree | /fundamentos-python/AT/03.py | 1,364 | 4.21875 | 4 | # Usando o Thonny, escreva uma função em Python chamada potencia.
# Esta função deve obter como argumentos dois números inteiros,
# A e B, e calcular AB usando multiplicações sucessivas
# (não use a função de python math.pow) e retornar o resultado da operação.
# Depois, crie um programa em Python que obtenha dois núme... | false |
d6c8cd38a45fbe47c95aeb01ce7387d4202dbdaf | jeffersonsouza/computer-engineering-degree | /fundamentos-python/TP3/01.py | 843 | 4.21875 | 4 | # Usando Python, faça o que se pede (código e printscreen):
# - Crie uma lista vazia;
# - Adicione os elementos: 1, 2, 3, 4 e 5, usando append();
# - Imprima a lista;
# - Agora, remova os elementos 3 e 6 (não esqueça de checar se eles estão na lista);
# - Imprima a lista modificada;
# - Imprima também o tamanho ... | false |
a93d3bd1ef9fee237e33689359553aef83b26b22 | sdawn29/cloud-training | /list_ex.py | 1,317 | 4.375 | 4 | #list -> class
l1 = list([10, 20, 30]) # a list of 3 elements
l2 = [10, 12.5, 'python', ['a','b']] #shortcut of creating a list
print(l2)
print(l2[1])
print(l2[2][1])
print(l2[-1:1:-1])
#add element ot the list
l2.append(200)
print('append=',l2)
l2.insert(2,300)
print('Insert=',l2)
l3 = [10,20]
l4 ... | true |
8eb9843678140e25e75f2a9030c2480d0fdd649c | SafiyatulHoque/Bootcamp-NSU | /Bootcamp 11/Pre Bootcamp Contest 11 (1)/Q.py | 436 | 4.625 | 5 | # Python3 code to demonstrate
# to extract words from string
# using split()
# initializing string
test_string = 'Adventures in Disneyland Two blondes were going to Disneyland when they came to a fork in the road. The sign read: "Disneyland Left." So they went home.'
# printing original string
print ("The original st... | true |
66ea622dc4018f5849cb4a2f938a7837ae418635 | shreyansh-tyagi/leetcode-problem | /power of 2.py | 808 | 4.25 | 4 | '''
Given an integer n, return true if it is a power of two. Otherwise, return false.
An integer n is a power of two, if there exists an integer x such that n == 2x.
Example 1:
Input: n = 1
Output: true
Explanation: 20 = 1
Example 2:
Input: n = 16
Output: true
Explanation: 24 = 16
Example 3:
Input: n = 3
Output... | true |
0c121b96785c7586221dd6a08d0a5ec24ee5abaf | shreyansh-tyagi/leetcode-problem | /wildcard matching.py | 1,248 | 4.28125 | 4 | '''
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where:
'?' Matches any single character.
'*' Matches any sequence of characters (including the empty sequence).
The matching should cover the entire input string (not partial).
Example 1:
Input: s = "... | true |
926c7b7076a25daef60b3d3b300670b30e73e575 | shreyansh-tyagi/leetcode-problem | /backspace string compare.py | 1,175 | 4.125 | 4 | '''
Given two strings s and t, return true if they are equal when both are typed into empty text editors. '#' means a backspace character.
Note that after backspacing an empty text, the text will continue empty.
Example 1:
Input: s = "ab#c", t = "ad#c"
Output: true
Explanation: Both s and t become "ac".
Example 2... | true |
4d5d7368ff9248788d9fbd3acf136b51a8f35c00 | shreyansh-tyagi/leetcode-problem | /planning a meeting.py | 1,748 | 4.25 | 4 | '''
You have to organize meetings today. There are meetings for today. Meeting must start at time and end at time . Unfortunately, there are only two meeting rooms available today. Consider meetings and intersecting in time if .
You cannot conduct two meetings in the same room at the same time.
Your task is to d... | true |
18e31179f424c66e561bcd7d88536f73381c423e | shreyansh-tyagi/leetcode-problem | /permutations.py | 662 | 4.125 | 4 | '''
Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Example 1:
Input: nums = [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
Example 2:
Input: nums = [0,1]
Output: [[0,1],[1,0]]
Example 3:
Input: nums = [1]
Output: [[1]]
... | true |
cc19150ea53ef523c336039b30c3d79dfd12fdd2 | ElizabethRoots/python_practice | /mini_projects/ft_converter.py | 711 | 4.40625 | 4 | #!/usr/bin/env python3
import sys
height = float(input("Enter your height in the format: ft.in "))
inches = height * 12
dvd = 7.48
creditCard = 3.375
iPadAir = 9.4
select = int(
input("Select unit of measurement: 1 = DVD case, 2 = Credit Cards, 3 = iPad Air Gen-One "))
def divide(inches, select):
formatted... | true |
351ecae3df591709bba7a5ad0e0c44005338b615 | calebhews/Ch.08_Lists_Strings | /8.0_Jedi_Training.py | 1,650 | 4.46875 | 4 | # Sign your name: Caleb Hews
'''
1.)
Write a single program that takes any of the three lists, and prints the average.
Use the len function. There is a sum function I haven't told you about.
Don't use that. Sum the numbers individually as shown in the chapter.
Also, a common mistake is to calculate the average each ti... | true |
fa2880ed5dfb7e0fe4986a84097af2ca38aa0eb4 | FazeelUsmani/Scaler-Academy | /017 String Algorithm/A3 reverseString.py | 1,038 | 4.28125 | 4 | /*
Reverse the String
Problem Description
Given a string A of size N. Return the string A after reversing the string word by word. NOTE:
A sequence of non-space characters constitutes a word.
Your reversed string should not contain leading or trailing spaces, even if it is present in the input string.
If there are mult... | true |
37209057e5842fb3a827b0588918d4ee291bcdfd | k4u5h4L/algorithms | /leetcode/Symmetric_Tree.py | 935 | 4.34375 | 4 | '''
Symmetric Tree
Easy
Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center).
Example 1:
Input: root = [1,2,2,3,4,4,3]
Output: true
Example 2:
Input: root = [1,2,2,null,3,null,3]
Output: false
'''
# Definition for a binary tree node.
# class TreeNode:
# ... | true |
a8ffbc2d433ae45bf4f87875e663b4853be83cc2 | k4u5h4L/algorithms | /nuclei/max_profit.py | 486 | 4.15625 | 4 | '''
For the given array of length and price find the maximum profit that can be gained.
'''
def maxProfit(prices):
max_profit = 0
min_price = prices[0]
for price in prices:
min_price = min(price, min_price)
max_profit = max(max_profit, price - min_price)
return m... | true |
fb775e5361af5b84e1b1be3bae5f526bab67ea19 | k4u5h4L/algorithms | /leetcode/ZigZag_Conversion.py | 1,955 | 4.34375 | 4 | '''
ZigZag Conversion
Medium
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: "PAHNAPLSIIGYIR"
Write the code that will take a... | true |
f6846b1ccb90f6eb86bee2970132941cf498c102 | k4u5h4L/algorithms | /leetcode/Second_Largest_Digit_in_a_String.py | 1,017 | 4.28125 | 4 | '''
Second Largest Digit in a String
Easy
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
An alphanumeric string is a string consisting of lowercase English letters and digits.
Example 1:
Input: s = "dfa12321afd"
Output: 2
Explanation: The ... | true |
0a7df1ce50f54435c9a653bd0c4c5bc54e6179a9 | k4u5h4L/algorithms | /leetcode/Rotate_Image.py | 1,123 | 4.46875 | 4 | '''
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 = [[1,2,3],[... | true |
cc9934f6d827570fd8bb3ad05b6acc36b3c37495 | k4u5h4L/algorithms | /leetcode/Add_to_Array-Form_of_Integer.py | 508 | 4.1875 | 4 | '''
Add to Array-Form of Integer
Easy
The array-form of an integer num is an array representing its digits in left to right order.
For example, for num = 1321, the array form is [1,3,2,1].
Given num, the array-form of an integer, and an integer k, return the array-form of the integer num + k.
'''
class Solution... | true |
f2da2236b2af5e8cc428d8bc6dac3e08b19e574c | k4u5h4L/algorithms | /leetcode/Set_Matrix_Zeroes.py | 926 | 4.28125 | 4 | '''
Set Matrix Zeroes
Medium
Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's, and return the matrix.
You must do it in place.
Example 1:
Input: matrix = [[1,1,1],[1,0,1],[1,1,1]]
Output: [[1,0,1],[0,0,0],[1,0,1]]
Example 2:
Input: matrix = [[0,1,2,0],[3,4,5,2],[1,... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.