blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
ac89d9024de18d1c8b50ecf983248ac2eb757e03 | connorS119987/CNA267-Spring-Semester-2020 | /CH05/23Lab5-3.py | 305 | 4.25 | 4 | #------------------------------------#
# Connor Seemann Seat 23 Lab 5.2 #
#------------------------------------#
# This program will display a staircase of numbers
print("This program will display a staircase of numbers")
for i in range(1, 7 + 1):
for j in range(1, i):
print(j, end='')
print()
| true |
b027f055ea16d1edd45afc9defb7d809a5c960d5 | ConnorMaloney/AOCStudy | /2018/Python/Sandbox/questionSix.py | 549 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Spyder Editor
This is a temporary script file.
"""
'''
Let a and b be positive integers such that ab + 1 divides a^2 + b^2.
Show that a^2 + b^2 / ab + 1 is the square of an integer.
'''
import random
from math import sqrt
def question_six(a,b):
return ((a**2 + b**2) / (a*b + 1))
d... | true |
5e4a761f319753507141b940763710350f5e8ab8 | LisCoding/Python-playground | /dictionary_basics.py | 546 | 4.625 | 5 | # Assignment: Making and Reading from Dictionaries
# Create a dictionary containing some information about yourself.
# The keys should include name, age, country of birth, favorite language.
# Write a function that will print something like the following as it executes:
my_info = {
"name": "Liseth",
"age": 27,
"countr... | true |
ba23cd3a47498efe55c1cffaa07a62b39ec74ccc | LisCoding/Python-playground | /coin_tosses.py | 1,395 | 4.15625 | 4 | # Assignment: Coin Tosses
# Write a function that simulates tossing a coin 5,000 times. Your function should print
# how many times the head/tail appears.
#
# Sample output should be like the following:
# Starting the program...
# Attempt #1: Throwing a coin... It's a head! ... Got 1 head(s) so far and 0 tail(s) so f... | true |
b459267ba763621fde1026adb4ceb2afdbe5cec8 | prithajnath/Algorithms | /Sorts/merge_sort.py | 967 | 4.1875 | 4 | #!/usr/bin/python3
# MergeSort
# Kevin Boyette
def merge_sort(array):
if len(array) <= 1:
return array
else:
left = []
right = []
middle = len(array) // 2
for eachLeftOfMiddle in array[:middle]:
left.append(eachLeftOfMiddle)
for eachRightOfMiddle in ... | false |
28c7d53836fef43aefe02088cafb730f63ca2502 | vinothini92/Sorting_algorithms | /mergesort_iterative.py | 1,030 | 4.1875 | 4 | def mergesort_iterative(nums):
length = len(nums)
if length < 2:
print "array is already in sorted order"
return
step = 1
while step < length:
i = 0
j = step
while j + step <= length:
merge(nums,i,i+step,j,j+step)
i = j + step
... | true |
5468009ffd7e5673c98643efbdfb0e8bbbac8d9e | Shreyassavanoor/grokking-coding-interview | /1_sliding_window/max_sum_subarray.py | 772 | 4.25 | 4 | '''Given an array of positive numbers and a positive number ‘k’,
find the maximum sum of any contiguous subarray of size ‘k’.
Ex:1
Input: [2, 1, 5, 1, 3, 2], k=3
Output: 9
Explanation: Subarray with maximum sum is [5, 1, 3].
'''
def find_max_sum_subaarray(arr, k):
window_start = 0
max_sum = 0... | true |
df7c65ec8e67a28961f914ce8ffeafb6ca35af38 | DizzleFortWayne/python_work | /Learning Modules/Python_Basics/bicycles.py | 467 | 4.53125 | 5 | ## Learning lists
bicycles=['trek','cannondale','redline','specialized']## brackets create list
##print(bicycles) prints full list
##print(bicycles[0]) ## prints first (0) on the list
##print(bicycles[0].title()) ## Capitalizes like a title
##print(bicycles[-1]) ## -1 prints the last of the list
## -2 is second fr... | true |
b4ebe9e15eeb10a523356d2047cb0c6b4b1b9c97 | nayana8/Prep1 | /Interview-Week2/goldStars.py | 1,789 | 4.125 | 4 | """
Alice is a teacher with a class of n children, each of whom has been assigned a numeric rating. The classroom is seated in a circular arrangement, with Alice at the top of the circle. She has a number of gold stars to give out based on each child's rating, but with the following conditions:
Each child must receive... | true |
b10dd96c07453971d05d96317426b0dafab1c873 | echau01/advent-of-code | /src/day7.py | 1,962 | 4.1875 | 4 | from typing import Dict
# Each bag type T is associated with a dict that maps bag types to the quantities
# of those bag types that T must contain.
rules: Dict[str, Dict[str, int]] = dict()
def contains(bag_type: str, target_type: str) -> bool:
"""
Returns True if a bag with type bag_type must eventually co... | true |
3a68961820b57fbe002b739c49dac2a725d600f1 | qidCoder/python_OOPbankAccount | /OOP_bankAcount.py | 2,482 | 4.21875 | 4 | #Created by Shelley Ophir
#Coding Dojo Sep. 30, 2020
# Write a new BankAccount class.
# The BankAccount class should have a balance. When a new BankAccount instance is created, if an amount is given, the balance of the account should initially be set to that amount; otherwise, the balance should start at $0.
cla... | true |
d10b96f7262f0b9e028a2fc0d72328c3aadebe21 | czer0/python_work | /Chapter4/4-3_counting_to_twenty.py | 326 | 4.40625 | 4 | # Using for loops to print the numbers 1 to 20
# Method 1 - create a list
numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
for numbers in numbers:
print(numbers)
print ("\n")
# Method 2 - generate list
numbers = [value for value in range (1,21)]
for numbers in numbers:
print(number... | true |
cb428fa6112712e7d084f7bfdfb94d26b202e11f | czer0/python_work | /Chapter7/7-3_multiples_of_ten.py | 262 | 4.15625 | 4 | prompt = "Enter a number, and I'll tell you if it's "
prompt += "a multiple of ten: "
number = input(prompt)
number = int(number)
if number % 10 == 0:
print(str(number) + " is a multiple of ten")
else:
print(str(number) + " is not a multiple of ten")
| true |
36f11b0637f48e7418019fd1aea58eeedbae3509 | czer0/python_work | /Chapter6/6-11_cities.py | 1,110 | 4.84375 | 5 | # Uses a dictionary called cities with the names of three cities as
# keys. Uses a nested dictionary of information about
# each city which includes the country that the city is in, its
# approximate population, and a fact about the city. The keys for each
# city’s dictionary are country, population, and fact
# Out... | true |
a4578f52a1ab2d87cdeca56f75a60dcf98a1f952 | feladie/D07 | /HW07_ch10_ex02.py | 793 | 4.25 | 4 | # I want to be able to call capitalize_nested from main w/ various lists
# and get returned a new nested list with all strings capitalized.
# Ex. ['apple', ['bear'], 'cat']
# Verify you've tested w/ various nestings.
# In your final submission:
# - Do not print anything extraneous!
# - Do not put anything but pass in... | true |
22d3c0954921f4cc18a50b7dd2a5242eec080dba | meekmillan/cti110 | /M6T2_McMillan.py | 369 | 4.40625 | 4 | #CTI-110
#M6T2 - feet to inches conversion
#Christian McMillan
#11/30
#This program will convert feet to inches
# km to mi
ft_inch = 12
def main():
# feet input
ft = float(input('Enter a distance in feet:'))
show_inch(ft)
def show_inch(ft):
# conversion
inch = ft * ft_inch
# display inch... | true |
6134935d22a54e6d840c065065136f3afb0d4d0f | CharlesIvia/python-exercises-repo | /Palindromes/palindrome.py | 306 | 4.25 | 4 | #Write a Python function that checks whether a word or phrase is palindrome or not
def palindrome(word):
text = word.replace(" ", "")
if text == text[::-1]:
return True
else:
return False
print(palindrome("madam"))
print(palindrome("racecar"))
print(palindrome("nurses run")) | true |
9fd654c67138f52c97a833d0bf12982f761aa27d | Abdur-Razaaq/python-operators | /main.py | 778 | 4.28125 | 4 | # Task 1 Solution
# Pythagoras
# Given two sides of a right angled triangle calculate the third side
# Get two sides from the user ie. AB & BC
ab = input("Please enter the length of AB: ")
bc = input("Please enter the length of BC: ")
ac = (int(ab)**2 + int(bc)**2)**(1/2)
print("AC is: " + str(ac))
# Calculating the ... | true |
4f8e1140f52b020a5f75ffe14e50e7ebb5847d38 | fsckin/euler | /euler-4.py | 604 | 4.21875 | 4 | # A palindromic number reads the same both ways.
# The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.
# Find the largest palindrome made from the product of two 3-digit numbers.
def palindrome(object):
object = str(object)
if object[::-1] == object:
return True
e... | true |
3f075fb88594147f94bc91f346d9987cb1ed95d3 | omertasgithub/data-structures-and-algorithms | /leet code/Array/1572. Matrix Diagonal Sum.py | 499 | 4.15625 | 4 | #1572. Matrix Diagonal Sum
#related topics
#array
mat = [[1,2,3],
[4,5,6],
[7,8,9]]
mat2 = [[1,1,1,1],
[1,1,1,1],
[1,1,1,1],
[1,1,1,1]]
mat3 = [[5]]
#first solution
def diagonalSum(mat):
l=len(mat[0])
s=0
for i in range(l):
s... | false |
556c10da0c21b743d598a383bbe8389a9f4f9374 | fhenseler/practicepython | /6.py | 543 | 4.5625 | 5 | # Exercise 6
# Ask the user for a string and print out whether this string is a palindrome or not.
# (A palindrome is a string that reads the same forwards and backwards.)
import myFunctions
word = myFunctions.get_str("Insert a word: ")
wordLower = word.lower()
wordLength = len(word)
reverse = ""
for index in range(... | true |
7aeabd445b25bb6fc050e44e02f7555ec99c25f3 | AndrewAct/DataCamp_Python | /Dimensionality Reduction in Python/4 Feature Extraction/02_Manual_Feature_Extraction_II.py | 658 | 4.125 | 4 | # # 6/17/2020
# You're working on a variant of the ANSUR dataset, height_df, where a person's height was measured 3 times. Add a feature with the mean height to the dataset, then drop the 3 original features.
# Calculate the mean height
height_df['height'] = height_df[['height_1', 'height_2', 'height_3']].mean(axis = ... | true |
28be55ad77877327a2cc547cb802d2c737b16191 | AndrewAct/DataCamp_Python | /Machine Learning for Time Series Data/1 Time Series and Machine Learning Primer/03_Fitting_a_Simple_Model_Classification.py | 1,153 | 4.28125 | 4 | # # 6/27/2020
# In this exercise, you'll use the iris dataset (representing petal characteristics of a number of flowers) to practice using the scikit-learn API to fit a classification model. You can see a sample plot of the data to the right.
# Print the first 5 rows for inspection
print(data.head())
# <script.py> o... | true |
cadef1d87824ed154302b2a7231c371009e4a739 | AndrewAct/DataCamp_Python | /Image Processing with Keras in Python/2 Using Convolutions/04_Convolutional_Network_for_Image_Classification.py | 786 | 4.15625 | 4 | # # 8/16/2020
# Convolutional networks for classification are constructed from a sequence of convolutional layers (for image processing) and fully connected (Dense) layers (for readout). In this exercise, you will construct a small convolutional network for classification of the data from the fashion dataset.
# Import... | true |
852dedaa543ac6a97839644fab333e1dd1bba6ca | AndrewAct/DataCamp_Python | /Introduction to TensorFlow in Python/2 Linear Models/06_Train_a_Linear_Model.py | 1,241 | 4.1875 | 4 | # # 7/29/2020
# In this exercise, we will pick up where the previous exercise ended. The intercept and slope, intercept and slope, have been defined and initialized. Additionally, a function has been defined, loss_function(intercept, slope), which computes the loss using the data and model variables.
# You will now de... | true |
d675355b3058bbb592cccab10fc5c111ab27c2b0 | AndrewAct/DataCamp_Python | /Hyperparameter Tunning in Python/1 Hyperparameter and Parameters/1 Hyperparameter and Parameters/01_Extracting_a_Logistic_Regression_Parameter.py | 2,626 | 4.1875 | 4 | # # 8/16/2020
# You are now going to practice extracting an important parameter of the logistic regression model. The logistic regression has a few other parameters you will not explore here but you can review them in the scikit-learn.org documentation for the LogisticRegression() module under 'Attributes'.
# This par... | true |
50948ffffc4106dbee4e19e0b1144a1f3f05c57b | zhudaxia666/shuati | /LeetCode/刷题/二叉树/144二叉树的前序遍历.py | 1,738 | 4.1875 | 4 | '''
给定一个二叉树,返回它的 前序 遍历。(通过迭代算法完成)
思路:
有两种通用的遍历树的策略:
深度优先搜索(DFS)
在这个策略中,我们采用深度作为优先级,以便从跟开始一直到达某个确定的叶子,然后再返回根到达另一个分支。
深度优先搜索策略又可以根据根节点、左孩子和右孩子的相对顺序被细分为前序遍历,中序遍历和后序遍历。
宽度优先搜索(BFS)
我们按照高度顺序一层一层的访问整棵树,高层次的节点将会比低层次的节点先被访问到。
从根节点开始,每次迭代弹出当前栈顶元素,并将其孩子节点压入栈中,先压右孩子再压左孩子。
在这个算法中,输出到最终结果的顺序按照 Top->Bottom 和 Left->Right... | false |
a0949891d44af529535b61c60a8e7de3d4d3cbff | dougscohen/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 1,050 | 4.25 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
"""
Takes in a word/phrase and returns the ... | true |
6f34824a78939e24f29dc71ad83496f2c7a9488f | karthikdwarakanath/PythonPrograms | /findMinSumArr.py | 625 | 4.1875 | 4 | # Minimum sum of two numbers formed from digits of an array
# Given an array of digits (values are from 0 to 9), find the minimum possible
# sum of two numbers formed from digits of the array. All digits of given array
# must be used to form the two numbers.
def findMinSum(inputList):
inList = sorted(inputList)
... | true |
194575590af98ef6cbdf73578daad8502e1c8705 | Daria-Lytvynenko/homework14 | /homework14.py | 2,444 | 4.125 | 4 | from functools import wraps
import re
from typing import Union
# task 1 Write a decorator that prints a function with arguments passed to it.
# NOTE! It should print the function, not the result of its execution!
def logger(func):
@wraps(func)
def wrap(*args):
print(f'{func.__name__} called ... | true |
680783c22a0b03f5fe6b97efc77a33731dce3894 | maxgud/Python_3 | /Exercise_38_arrays.py | 1,560 | 4.125 | 4 | #this is just a variable that is equal to a string
ten_things = "Apples Oranges Crows Telephone Light Sugar"
print("Wait there are not 10 things in that list. Let's fix that.")
#this turns the variable into an array
#it splits the array where ever there is a ' ' aka space
stuff = ten_things.split(' ')
#this is a secon... | true |
27937d9585a75e3da0480f28d811c919247390ae | siggioh/2019-T-111-PROG | /exams/retake/grades.py | 1,552 | 4.125 | 4 | def open_file(filename):
''' Returns a file stream if filename found, otherwise None '''
try:
file_stream = open(filename, "r")
return file_stream
except FileNotFoundError:
return None
def read_grades(file_object):
''' Reads grades from file stream and returns them as a list... | true |
edc7cb3f249f29202907a23c11f48c0981bee364 | WQ-GC/Python_AbsoluteBeginners | /CH5_SharedReferences.py | 1,607 | 4.25 | 4 | #Shared References
myList = [1,2,3,4,5]
print(type(myList), " myList: ", myList)
myListRef1 = myList
myListRef2 = myListRef1
print(type(myListRef1), " myListRef1 is a reference to myList")
print(type(myListRef2), " myListRef2 is a reference to myList")
for item in myList:
item = 111
#print("item: ", item)
... | false |
f00e7ad1364e2e4fccf0028f943c28e49a86d3e2 | alshil/zoo | /square.py | 603 | 4.28125 | 4 | #Depends on the figure name an app calculates figure`s square
import math
figure_name = str(input("figure name "))
if figure_name == "triangle":
a = float(input ("1 side "))
b = float(input ("2 side "))
c = float(input ("3 sideа "))
if a + b > c or b + c > a or c + a > b:
p = (a + b + c) / 2
print(p * (p -a) ... | true |
4845f043a91b35d0599e68681f2030996161e541 | JaneNjeri/Think_Python | /ex_10_05.py | 569 | 4.15625 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 28.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 10. Lists
# Exercise 10.5
# Write a function called chop that takes a list, modifies it
# by removing the f... | true |
08a13096dd54f87860a2bfdfd89540d998ab6d71 | JaneNjeri/Think_Python | /ex_13_3.py | 2,660 | 4.125 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 29.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 13. Case study: data structure selection
#STATUS: check for refactoring
# Exercise 13.3
# Modify the progra... | true |
a48d58eebbac192fb4210041e733d640004d1cef | JaneNjeri/Think_Python | /ex_03_4.py | 1,522 | 4.5625 | 5 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 24.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 3. Functions
# Exercise 3.4
# A function object is a value you can assign to a variable or
# pass as an argu... | true |
5cc5ecde9e975a12d7e32f2c34185708d352cb52 | JaneNjeri/Think_Python | /ex_09_4_2.py | 799 | 4.34375 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 27.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 9. Case study: word play
# Exercise 9.4
# Can you make a sentence using only the letters acefhlo?
# Other th... | true |
8db91bd009e8a4fc9c9e5f0bddec486845f13364 | JaneNjeri/Think_Python | /ex_08_01.py | 580 | 4.71875 | 5 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 25.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 8. Strings
# Exercise 8.1
# Write a function that takes a string as an argument and
# displays the letters ... | true |
bd89a3468942ea72efeb8da8a24d479b905100dd | JaneNjeri/Think_Python | /ex_12_1.py | 389 | 4.375 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 29.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 12. Tuples
# Exercise 12.1
# Write a function called sumall that takes any number of
# arguments and return... | true |
27fba10b5b159591924eb0ab1e00a8ac92d8dbdf | JaneNjeri/Think_Python | /ex_06_8.py | 1,076 | 4.125 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 25.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 6. Fruitful functions
# Exercise 6.8
# The greatest common divisor (GCD) of a and b is the largest number
# ... | true |
151f141f0ed7e3dd88904c4ebc30af256887ee43 | JaneNjeri/Think_Python | /ex_06_2.py | 1,119 | 4.21875 | 4 | #!/usr/bin/python
#AUTHOR: alexxa
#DATE: 24.12.2013
#SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey
# http://www.greenteapress.com/thinkpython/html/index.html
#PURPOSE: Chapter 6. Fruitful functions
# Exercise 6.2
# Use incremental development to write a function called
# hypotenuse ... | true |
4e95ec47fd13d8432cf465c12bc2cd46bd35b586 | LeeSinCOOC/Data-Structure | /chapter1/C-1.26.py | 267 | 4.21875 | 4 | def arithmetic():
a = int(input('a:'))
b = int(input('b:'))
c = int(input('c:'))
if a + b == c or a == b - c or a*b == c:
return True
return False
# 算术逻辑的本质是?
# 还有许多情况需要考虑
a = arithmetic()
print(a)
| false |
915cb0ad8cddbe30e4af593993eb10b7a11a4292 | MichaelCzurda/Python-Data-Science-Beispiele | /Python_Basics/07_RegularExpression/0710_substitute_strings.py | 1,442 | 5.03125 | 5 | #! python3
#0710_substitute_strings.py - Substituting Strings with the sub() Method
#Regular expressions can not only find text patterns but can also substitute
#new text in place of those patterns. The sub() method for Regex objects is
#passed two arguments. The first argument is a string to replace any matches.
#The... | true |
55742544b628d6d08ee04f8f87a9fc0947c3578d | MichaelCzurda/Python-Data-Science-Beispiele | /Python_Basics/09_Organizing_Files/0905_folder_into_zip.py | 1,984 | 4.34375 | 4 | #!python3
#0905_folder_into_zip.py - Project: Backing Up a Folder into a ZIP File
#create ZIP file “snapshots” from an entire folder. You’d like to keep different versions, so you want the ZIP file’s filename to increment each
#time it is made; for example, {name}_1.zip, {name}_2.zip, {name}_3.zip, and so on.
#Write ... | true |
456c1823e4f5230bcd742e0592ed3dcd890f08b1 | Alexey-Nikitin/PythonScripts | /pycode.py | 1,634 | 4.21875 | 4 | def calc():
print("Введите какое действие вы хотите сделать. (+, -, *, /)")
whattodo = input()
if whattodo != "+" and whattodo != "-" and whattodo != "*" and whattodo != "/":
print("Ошибка! Нужно ввести только +, -, * или /")
print(" ")
calc()
else:
print("Введите два числа с которыми нужно выполнить дейс... | false |
a59b90c5687d90c4d59de9e38c721a52d933eea5 | ShoonLaeMayLwin/SFUpython01 | /If_Else_Statements.py | 2,286 | 4.15625 | 4 | #Boolean Expression -> True or False
print(20 > 10)
print(20 == 10)
print(20 < 10)
print(bool("Hello World"))
print(bool(20))
Python Conditions
Equals -> x == y
Not Equals -> x != y
Less than -> x < y
Less than or equal to -> x <= y
Greater than -> x > y
Greater than or equal to -> x >= y
Boole... | false |
d16edae81fe36827801aa7681389c8fc42e73755 | Safal08/LearnPython | /Integers & Float.py | 852 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Apr 21 09:49:00 2020
@author: safal
"""
num=3
print(type(num)) #shows the integer
num1=3.14
print(type(num1)) #shows the float
#Arithmetic Operations
print(5+2) #Addition
print(5-2) #Subtraction
print(5/2) #Division
print(5//2) #Floor Division
print(5**2) #Exponent
print(... | true |
6fbf62b2549c9035c593df7e5bea53ee8a7ea98e | Granada2013/python-practice | /tasks/All_Balanced_Parentheses.py | 615 | 4.25 | 4 | """
Write a function which makes a list of strings representing all of the ways you can balance n pairs of parentheses
Examples:
balanced_parens(0) => [""]
balanced_parens(1) => ["()"]
balanced_parens(2) => ["()()","(())"]
balanced_parens(3) => ["()()()","(())()","()(())","(()())","((()))"]
"""
from functools import ... | true |
64c795e5bdc98fc5cafd923369d6ed8bc117b035 | lel352/PythonAulas | /Aula15/Aula15b.py | 600 | 4.125 | 4 | #f string
soma = 10
print(f'Soma é {soma}')
#f string
nome = 'Julio'
idade = 33
print(f'O {nome} tem {idade} anos.')
salário = 987.35
print(f'O {nome} tem {idade} anos e ganha R${salário:.2f}')
print(f'O {nome} tem {idade} anos e ganha R${salário:.1f}')
print(f'O {nome:^20} tem {idade} anos e ganha R${salário... | false |
ce3f48c4f55ae5cbbef40d5f3c29abe81d06ceb5 | lel352/PythonAulas | /PythonExercicios/Desafio033.py | 459 | 4.15625 | 4 | print('=========Desafio 033========')
numero1 = int(input('Numero 1: '))
numero2 = int(input('Numero 2: '))
numero3 = int(input('Numero 3: '))
maior = numero1
menor = numero1
if maior < numero2 and maior > numero3:
maior = numero2
elif maior < numero3:
maior = numero3
if menor > numero2 and menor < nu... | false |
0994ff0f127182eaa3954f8c31c10b1228912216 | panu2306/Python-programming-exercises | /geeksforgeeks/string_problems/palindrome.py | 882 | 4.625 | 5 | # Python program to check if a string is palindrome or not
def using_for(sent_string):
s = ""
for c in sent_string:
s = c + s
return s
def using_reversed(sent_string):
s = "".join(reversed(sent_string))
return s
def using_recursion(sent_string):
if(len(sent_string) == 0):
... | false |
ae2da29ae4d1fc6346d1db65a497aa018e5d57ab | Elkip/PythonMorsels | /add.py | 1,578 | 4.25 | 4 | """
09/18/2019
a function that accepts two lists-of-lists of numbers and returns one list-of-lists with each of the corresponding
numbers in the two given lists-of-lists added together.
It should work something like this:
>>> matrix1 = [[1, -2], [-3, 4]]
>>> matrix2 = [[2, -1], [0, -1]]
>>> add(matrix1, matrix2)
[[3,... | true |
697a58f2e0289a9ea3aeef8bfd3fc2fad179c4c7 | Siddiqui-code/Python-Problems-Lab-6 | /factorial.py | 379 | 4.28125 | 4 | # Nousheen Siddiqui
# Edited on 02/19/2021
# Question 6:A for statement is used to calculate the factorial of a user input value.
# Print this value as well as the calculated value using the factorial function in the math module.
import math
factorial = int(input("Provide a number"))
x=1
for i in range(1, fa... | true |
4786d5aa3b0128ad503b2fdee1b1587fb7ec5642 | ChristopherCaysido/CPE169P-Requirements | /Mod1_PE01/recursive.py | 1,232 | 4.65625 | 5 |
'''
Write a recursive function that expects a pathname as an argument.
The path- name can be either the name of a file or the name of a directory.
If the pathname refers to a file, its name is displayed,
followed by its contents. Otherwise, if the pathname refers to a directory,
the function is applied to each nam... | true |
a114fbc6d189ae3ae0d0393eb6090ccfec1b6d95 | nicholsonjb/PythonforEverybodyExercises | /exercise4.6.py | 2,119 | 4.15625 | 4 | # Written by James Nicholson
# Last Updated March 27, 2019
#Use a costum function to do the following:
# Given (1) number of hours, and (2) rate of pay
# This program computes gross pay according to the formula: number of hours * rate of pay
#For hours worked beyond 40. pay = 1.5 * number of hours * rate of pay
#Use t... | true |
78060ff7bb9c0f4be4a3ba920430cbfe4b2cc845 | nicholsonjb/PythonforEverybodyExercises | /Data 620 Assignments/Assignment8.2-score-function.py | 1,688 | 4.21875 | 4 | #Data 620 Assignment 8.2 Python Score
#Severance Chapter 4 - Exercise 7 – ASSIGNMENT
#Written by James Nicholson
#Last Updated March 27, 2019
#Use a custome function to do the following:
# Write a program to prompt for a score between 0.0 and
#1.0. If the score is out of range, print an error message. If the score is
... | true |
eba0511a4332caddb52f67914e1f1b307b8cf92e | kashyap99saksham/python | /chapter12.py | 387 | 4.21875 | 4 | # INTRO OF LAMBDA EXPRESSIONS(ANONYMUS FUNCTION)
add = lambda a,b : a+b #USE ADD AS A NORMAL FUNCTION
print(add(2,3))
# MAKE IS_EVEN ODD PRGM USING LAMBA FUNCTION
e_o = lambda a : a%2==0
print(e_o(4))
# OR USING IF ELSE
e_o = lambda a : True if a%2==0 else False
print(e_o(4))
# PRINT LAST C... | false |
58c42b2fab76b1367bd43c79a2d13c8e8cbe6dac | kashyap99saksham/python | /chapter6.py | 1,327 | 4.375 | 4 | # # TUPLE DATA STRUCTURE
# # TUPLE CAN STORE ANY TYPE OF VALUES
# # MOST IMPORTANT , TUPLE ARE IMMUTABLE : CANT MODIFY/CHANGES
# # NO APPEND,NO INSERT,NO POP,NO REMOVE IN TUPLE
# # TUPLE ARE FASTER THEN LIST
# t = ('a','b','c')
# print(t)
# # METHODS USED WITH TUPLES
# # COUNT : COUNT ITEM IN TUPLE
# # LEN :... | false |
e75ca1fbf6c29ec375c0f80a1fa8514c5a7497c7 | GulzarJS/Computer_Science_for_Physics_and_Chemistry | /PW_2/circle.py | 2,338 | 4.125 | 4 | import math as mt
import random
import time as t
# Functions for finding area of circle with trapezoid method
# Function to find the angle between radius and the part until to chord
def angle_of_segment(r, a):
cos_angle = a / r
angle = mt.acos(cos_angle)
return angle
# Function to find ... | true |
218258b57bd2792615610fb9f04b18e37518678b | ChangXiaodong/Leetcode-solutions | /1/225-Implement-Stack-using-Queues.py | 1,778 | 4.1875 | 4 | '''
Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.
pop() -- Removes the element on top of the stack.
top() -- Get the top element.
empty() -- Return whether the stack is empty.
Notes:
You must use only standard operations of a queue -- which means only push to back, p... | true |
a7b5005ded6f1bc65d6fcc82aacacca7f6e41a36 | divyaparmar18/saral_python_programs | /maximum.py | 707 | 4.1875 | 4 | # here we are making a function which will take list of students marks and print their highest marks
def max_num(list_of_marks):# here we made a function of name max_num
index = 0# here we declared the index of the list as 0
while index < len(list_of_marks):# here we give the condition to run the loop till the... | true |
428636df3ef2962a5071c0d31a2dd1da4e3848aa | divyaparmar18/saral_python_programs | /Alien.py | 2,821 | 4.15625 | 4 | # here we will make a game in which we will fight with the alien
from random import randint # allows you to generate a random number
# variables for the alien
alive = True
stamina = 10
# this function runs each time you attack the alien
def report(stamin):
if stamin > 8:#here we give the condition
print... | true |
d30e41a2f8bf944b1969a547f5898b48c5d3c1ce | divyaparmar18/saral_python_programs | /nested.py | 598 | 4.21875 | 4 | age = (input("enter the age:"))# here we will se the nested condition which means condition inside a condition, so hewre we will take the age of user
if age > 5:# so if the age of user is more thn 5
print ("you can go to school")# this will be printed
if age > 18:# condition
print ("you can vote")#if condition... | true |
49df96e91a1b039335488c7ce1b2bdf4a8e2bd86 | divyaparmar18/saral_python_programs | /input.py | 1,034 | 4.4375 | 4 | #here we will take the input from the user and we will see how to work with strings ,integers and floats
name = raw_input("put your name: ")
surname = raw_input("put your surname: ")
whole_name = (name + surname)
print (whole_name)#this will add the string and print both the srting to gether bcoz raw input means that... | true |
955e48e827cd268c3f1f9ce579b238fc280cf7b4 | suraj-singh12/python-revision-track | /09-file-handling/questions/91_read_find.py | 459 | 4.1875 | 4 | try:
file = open("myfile.txt","r")
except IOError:
print("Error opening the file!!")
exit()
file = file.read()
file = file.lower() # converting all read content into lowercase, as we are ignoring the case in finding the word,
# i.e. for us twinkle and Twinkle are same
word = "t... | true |
135d327f5aeb122c5c61838c1bcd42170afcc3af | mandalaalex1/MetricsConverionTool | /MetricsConversionTool.py | 1,906 | 4.15625 | 4 | print("Options:")
print("[P] Print Options")
print("[C] Convert from Celsius")
print("[F] Convert from Fahrenheit")
print("[M] Convert from Miles")
print("[KM] Convert from Kilometers")
print("[In] Convert from Inches")
print("[CM] Convert from Centimeters")
print("[Q] Quit")
while True:
Option1 = input("Option: ")... | false |
c70b9cde6d3208965fe1b4508b2ce84bea37643f | helalkhansohel/Python_Functions_Libraries | /Python Core/Basic Command/JSON.py | 682 | 4.125 | 4 |
#-------------------JSON----------------------------------
def MyJson():
import json
#Convert from JSON to Python:
x='{"Name":"Helal" ,"age":26}'
y=json.loads(x)
print(y["Name"])
#Convert from Python to JSON:
x={
"name": "John",
"age": 30,
"city": "New York"
}
y=json.dumps(x)
print(y)... | false |
014ccca1f5bf022a761b58747a3720981c2dc45f | publicmays/LeetCode | /implement_queue_using_stacks.py | 1,491 | 4.46875 | 4 |
class Queue(object):
def __init__(self):
self.stack1 = [] # push
self.stack2 = [] # pop
def push(self, x):
self.stack1.append(x)
def pop(self):
if not self.stack2:
self.move()
self.stack2.pop()
def peek(self):
if not self.stack2:
... | true |
af852014b50d6e1b423f6bc18ab2d6ab4da33e18 | Shri-85535/OOPS | /Class&Object.py | 695 | 4.125 | 4 | '''
"Class" is a design for an object. Without design we cannot create anything.
A class is a collection of Objects
The Object is an entity that has a state and behavior associated with it. More specifically, any single integer or any single string is an object
'''
class Computer:
#1 Attributes(Variables)
#2 ... | true |
1726c1c108097b18d5f0a8fd73a6aab037834eca | aeciovc/sda_python_ee4 | /SDAPythonBasics/tasks_/task_03.py | 525 | 4.375 | 4 | """
Write a program that based on the variable temperature in degrees Celsius - temp_in_Celsius (float),
will calculate the temperature in degrees Farhenheit (degrees Fahrenheit = 1.8 * degrees Celsius + 32.0)
and write it in the console.
Get the temperature from the user in the console using argument-less input().
""... | true |
cfe42df919522c35dc69de03d479b1fa81ba53a4 | AbhishekKumarMandal/SL-LAB | /SL_LAB/partA/q8.py | 1,112 | 4.34375 | 4 | from functools import reduce
l=[1,2,3,4,5,6]
m=[x*3 for x in l] #using list comprehension
print('list l: ',l)
print('list m: ',m)
#using reduce and lambda function
print('sum of list l: ',reduce(lambda a,b:a+b, l))
print('sum of list m: ',reduce(lambda a,b:a+b, m))
'''
A list comprehension generally consist of these ... | true |
7f2927ae1943864e1c0fcafd2a258e208b59f234 | talt001/Java-Python | /Python-Fundamentals/Loan Calculations/combs_loan_calculations_program.py | 1,840 | 4.3125 | 4 | #Step 1 write a python function that will calculate monthly payments on
# a loan.
#Step 2 pass the following to your function
#Principle of $20,000, with an APR of 4% to be paid in
# 1.) 36 months
# 2.) 48 months
# 3.) 60 months
# 4.) 72 months
#Step 3 include code for user supplied loan terms and comment out... | true |
0ee112181b34e75917e80e23dd3411f06d3a3282 | andy-buv/LPTHW | /mystuff/ex33.py | 769 | 4.1875 | 4 | from sys import argv
x = int(argv[1])
y = int(arg[2])
# Remember to cast an input as an integer as it is read in as a string
# I forgot this because I was not using the raw_input() method
def print_list_while(number, step):
i = 0
numbers = []
while i < number:
print "At the top i is %d" % i
numbers.append(i)
... | true |
b96ec4a68ba1b9b370fb9c690cbb3e8cf0f1335d | andy-buv/LPTHW | /mystuff/ex23.py | 893 | 4.25 | 4 | Reading from Python Source Code for General Assembly DAT-8 Course
github.com
launchpad.net
gitorious.org
sourceforge.net
bitbucket.org
# LISTS
nums = [5, 5.0, 'five'] # multiple data types
nums # print the list
type(nums) # check the type: list
len(nums) ... | true |
43d84ba163b1f8a4ecbfd84df0d54433b8e890f4 | Rita-Zey/python_project1 | /coffee_machine.py | 2,746 | 4.1875 | 4 | # Write your code here
import sys
ESPRESSO = [250, 0, 16, 4]
LATTE = [350, 75, 20, 7]
CAPPUCCINO = [200, 100, 12, 6]
class Coffee:
all_water = 400
all_milk = 540
all_beans = 120
all_cups = 9
all_money = 550
def coffee_machine_has():
print('The coffee machine has:')
print(Coffee.all_wate... | true |
6eba0e3cfaca03bc2754cc690c1cfa5468af787e | aprilxyc/coding-interview-practice | /ctci/ctci-urlify.py | 695 | 4.3125 | 4 | # problem 1.3 ctci
""" Write a method to replace all spaces in a string with %20. You may assume that the string
has sufficient space at the end to hold the additional characters, and that you are given
the 'true' length of the string.
E.g.
Input: 'Mr John Smith ", 13
Output: 'Mr%20John%20Smith'
"""
def urlify(str... | true |
ba3c1522f31525085aede553ba0a476e9a5ddb57 | aprilxyc/coding-interview-practice | /leetcode-problems/1252-cells-odd-values.py | 1,917 | 4.21875 | 4 | # nested list comprehension example
# answer = [[i*j for i in range(1, j+1)] for j in range(1, 8)]
indices = [[0,1],[1,1]]
matrix = [[0 for a in range(3)] for b in range(2)]
print(matrix)
def oddCells(self, n: int, m: int, indices: List[List[int]]) -> int:
# O(N^2) because it has to go through the list of indices... | true |
6cfaa8f0048bff952d17bfb591b90849423cf5f4 | aprilxyc/coding-interview-practice | /leetcode-problems/350-intersection-of-two-arrays-ii.py | 2,771 | 4.15625 | 4 | """
https://leetcode.com/problems/intersection-of-two-arrays-ii/
Good solution to look at:
https://leetcode.com/problems/intersection-of-two-arrays-ii/discuss/82247/Three-Python-Solutions
What if the given array is already sorted? How would you optimize your algorithm? Use pointers
What if nums1's size is small compa... | true |
880c9c52bc8fd1faa1ede09b498470129b007018 | aprilxyc/coding-interview-practice | /leetcode-problems/232-implement-queue-using-stacks.py | 1,773 | 4.15625 | 4 | """
https://leetcode.com/problems/implement-queue-using-stacks/
"""
# a very bad first implementation 27/01
# space is O(N)
# time complexity stays constant and is O(1) amortised
# we look at the overarching algorithm's worst case
class MyQueue:
def __init__(self):
"""
Initialize your data structu... | true |
194db0f16c84d40c6b193d54c0810579e7eba82b | emtee77/PBD_MJ | /muprog/cities.py | 634 | 4.25 | 4 | myfile = open('cities.txt', 'w') #This is used to open a file, w-writes to the file
myfile.write("Dublin\n")
myfile.write("Paris\n")
myfile.write("London\n")
myfile.close() #it is good to always close the file when you are done with it
myfile = open("cities.txt", "r") #This is used to open a file, r-reads the file
... | true |
19177be68bd64b821ed2ac20f347cfd85ca5548d | typemegan/Python | /CorePythonProgramming_2nd/ch09_files/commentFilter.py | 398 | 4.25 | 4 | #!/usr/bin/python
'''
Exercise 9-1:
display all the lines of file, filtering the line beginning with "#"
Problem:
extra credit: strip out comments begin after the first character
'''
name = raw_input('enter a filename> ')
f = open(name,'r')
i = 1 # counting file lines
for eachLine in f:
if eachLine.[0] != '#':... | true |
df495a122a08bbde2fdbe1b6b03bbd15c4f343cd | typemegan/Python | /Errors/Exception/StandardError/RuntimeError/maxRecursionDepth.py | 346 | 4.1875 | 4 | '''
there is a limit in recursion depth
'''
#example
def Factorial(n):
if n > 1:
return n * Factorial(n-1)
elif n == 1 or n == 0:
return 1
'''
test result:
10! = 3628800
1000!: RuntimeError:maximum recursion depth exceeded
原因:递归展开(深度)存在限制
试验结果:当n>=999时报错
'''
| false |
5e05c5a64587e06dcb7422350c90fb683fe5ef5c | typemegan/Python | /CorePythonProgramming_2nd/ch08_loops/getFactors.py | 447 | 4.15625 | 4 | #!/usr/bin/python
'''
Exercise 8-5:
get all the factors of a given integer
'''
def getFactors(num):
facts = [num]
# while
# count = num/2
# while count >= 1:
# if num % count == 0:
# facts.append(count)
# count -= 1
# for
for count in range(num/2, 0, -1):
if num % count == 0:
facts.append(count)
retu... | true |
07782b22ea28d71b07d515bca3affed7684d3193 | PxlPrfctJay/currentYear | /leapYear.py | 2,189 | 4.4375 | 4 | # A Program that has three functions to return a day of year
#Function One:
# A function that checks if a given year is a leap year
#Function Two:
# A function that returns number of days in month
# (28,29,30,31) depending on the given month(1-12) and year
# which uses isYearLeap(year) to determine a leap year
#Func... | true |
dc7570703a8820221bdbb033220db2a9d6427063 | Adioosin/DA_Algo_Problems | /Sum of pairwise Hamming Distance.py | 1,273 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
Hamming distance between two non-negative integers is defined as the number of positions at which the corresponding bits are different.
For example,
HammingDistance(2, 7) = 2, as only the first and the third bit differs in the binary representation of 2 (010) and 7 (111).
Given an array o... | true |
b1e8af4694fc7f951b4a0cc8bbb6acda2549f3be | bn06a2b/Python-CodeAcademy | /pizza_lens_slice.py | 838 | 4.625 | 5 | #addding toppings list
toppings=['pepperoni','pineapple','cheese','sausage','olives','anchovies','mushrooms']
#adding corresponding price list
prices=[2,6,1,3,2,7,2]
#number of pizzas and printing string to show no. of pizzas
num_pizzas=len(toppings)
print("We sell " +str(num_pizzas) + " different kinds of pizza!... | true |
23b372d9bc54c9d5989bc21c8af1fe1312dd1995 | Dannyh0198/Module-3-Labs | /Module 3 Labs/Working Area.py | 422 | 4.15625 | 4 | my_list = [1, 2, 4, 4, 1, 4, 2, 6, 2, 9]
list_without_duplicates = []
for number in my_list: # Browse all numbers from the source list.
if number not in list_without_duplicates: # If the number doesn't appear within the new list...
list_without_duplicates.append(number) # ...append it here.
my_list = list_without... | true |
170afd5d9894788e49bd328bce7bca8987b49458 | parveenkhatoon/python | /ifelse_question/age_comp.py | 338 | 4.25 | 4 |
age = int(input("Enter the age:"))
if age <= 2:
print("person is baby")
if age > 2 and age < 4:
print("person is a toddler")
if age >= 4 and age < 13:
print("person is the kid")
if age >= 13 and age < 20:
print("person is a teenager")
if age >= 20 and age < 65:
print("person is an adult")
if age >= 65:
print("pe... | true |
84e282e8ec93ff960e6ddf42b3605023ce875b38 | parveenkhatoon/python | /mix_logical/reverse.py | 522 | 4.1875 | 4 |
'''reverse with while loop'''
number=int(input("number:"))
reverse=0
while (number>0):
reminder=number%10
reverse=(reverse*10)+reminder
number=number//10
print("reverse number",reverse)
'''reverse is using if condition'''
num=int(input("number:"))
rev=0
if num>1:
ram=num%10
rev=(rev*10)+ram
num=num//10
i... | true |
bfd8c45b831a6d3e40b30b7645b20a8ad51051ab | englisha4956/CTI110 | /P1HW2_BasicMath_EnglishAnthony.py | 575 | 4.21875 | 4 | # Netflix MONTHLY & ANNUAL FEE GENERATOR +TAX
# 9/26/2021
# CTI-110 P1HW2 - Basic Math
# Anthony English
#
charge = 17.99
tax = charge * .06
monthly = charge + tax
annual = monthly * 12
name = ('Netflix')
print('Enter name of Expense:', end=' ')
name = input()
print('Enter monthly charge:', end=' ')
mo... | true |
d6d98709ce72d98aedc1f3eb3e287d6239d36564 | abhirathmahipal/Practice | /Python/Core Python Programming/Chapter - 2/BasicForLoops.py | 497 | 4.53125 | 5 | # Iterating over a for loop. It doesn't behave like a traditional
# counter but rather iterates over a sequence
for item in ['email', 'surfing', 'homework', 'chat']:
print item,
# Modifying for loops to behave like a counter
print "\n"
for x in xrange(10):
print x,
# Iterating over each character in a s... | true |
311b031bcd268c43ddce442463c06b62c7e550f2 | tedmcn/Programs | /CS2A/PA1/prime.py | 713 | 4.3125 | 4 | def prime(num):
"""
Tester - Takes an input number from the user and tests whether it is prime
or not. Then, it returbns True or False depending on the number and prompts
the user if it is prime or not. Returns True or False if prime or not.
Example answers:
prime(10)
prime(227)
... | true |
74c22afb2fcbc02a2ca574e6e780f62a1c6bcfce | htbo23/ITP-Final-Project | /Waiter.py | 2,793 | 4.125 | 4 | # Tiffany Bo
# ITP 115, Fall 2019
# Final Project
from Menu import Menu
from Diner import Diner
class Waiter():
def __init__(self, menu):
# sets it to an empty list
self.diners = []
self.menu = menu
# adds a diner to the list
def addDiner(self, diner):
self.diners.append(diner)
#finds how many diners there... | true |
6db19a61d62c41144e6dcdbd510e8a6c63f4c8d8 | vikasvisking/courses | /python practic/list_less_then_10.py | 850 | 4.375 | 4 | """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 element in a:
if element < 5 :
print(element)
# Instead of printing the elements one by ... | true |
f36e514a1fad77868fb66799b4ea313d0708ebb1 | GuuMee/ExercisesTasksPython | /1 Basics/25_units_of_time2.py | 1,215 | 4.40625 | 4 | """
In this exercise you will reverse the process described in the previous exercise.
Develop a program that begins by reading a number of seconds from the user.
Then your program should display the equivalent amount of time in the form
D:HH:MM:SS, where D, HH, MM, and SS represent days, hours, minutes and sec�onds res... | true |
54e634be4757a88da539d5db29f0ac33efb69a82 | GuuMee/ExercisesTasksPython | /5 Lists/_116_latin_improved.py | 2,508 | 4.4375 | 4 | """
Extend your solution to Exercise 115 so that it correctly handles uppercase letters and
punctuation marks such as commas, periods, question marks and exclamation marks.
If an English word begins with an uppercase letter then its Pig Latin representation
should also begin with an uppercase letter and the uppercase l... | true |
566912a27657e29b961c7a24fcc3fa76c65d2d94 | GuuMee/ExercisesTasksPython | /4_Functions/94_random_password.py | 1,216 | 4.59375 | 5 | """
Write a function that generates a random password. The password should have a
random length of between 7 and 10 characters. Each character should be randomly
selected from positions 33 to 126 in the ASCII table. Your function will not take
any parameters. It will return the randomly generated password as its only r... | true |
279b21d9e3839e9755e24e8fdf682135caab2d6a | GuuMee/ExercisesTasksPython | /1 Basics/23_area_polygon.py | 804 | 4.5 | 4 | """
A polygon is regular if its sides are all the same length and the angles between all of
the adjacent sides are equal. The area of a regular polygon can be computed using
the following formula, where s is the length of a side and n is the number of sides:
area = (n*s^2)/4*tan(pi/n)
Write a program th... | true |
4a762a39608178aca8325026ef78449181d91656 | GuuMee/ExercisesTasksPython | /1 Basics/31_sum_of_digits.py | 594 | 4.125 | 4 | """
Develop a program that reads a four-digit integer from the user and displays the sum
of the digits in the number. For example, if the user enters 3141 then your program
should display 3+1+4+1=9.
"""
# Read the input of the digits from the user
digits = input("Enter the 4-digit integer number: ")
# Convert to int ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.