blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
90ce5be2b14021e4a40e2682612c6c7fffceea5b | maryakinyi/trialgauss | /hon.py | 974 | 4.1875 | 4 |
import math
def calculate_area_of_circle(radius):
area=math.pi*(radius*radius)
print("%.2f" % area)
calculate_area_of_circle(6)
def area_of_cylinder(radius,height):
area=math.pi*(radius*radius)*height
print("%.2f" %area)
area_of_cylinder(23,34)
player_name = input("Hello, What's your name?")
number_o... | true |
12beda910c4fcbb13e1b9094142c8140a2b47675 | marwanforreal/SimpleCeaserModular | /code.py | 860 | 4.125 | 4 | # this is just a fun project you can use it for whatever
import string
import re
#List Of Upper Case Letters For Cipher
A = list(string.ascii_uppercase)
Cipher = []
#To Decrypt Or Encrypt
Flag = input("To Encrypt Enter 1 to Decrypt Enter 0: ")
while(True):
Key = int(input("Please Enter a Key Between 1 and 25: "... | true |
d0e47a40d7dc896f2646c85ba6b70ddfc413af57 | AkibSamir/FSWD_Python_Django | /third_class.py | 765 | 4.21875 | 4 | # Set
# declaration
data_set = set()
print(type(data_set))
data_set2 = {1, 2, 3, 4, 5}
print(data_set2, type(data_set2))
# access item
# print(data_set2[1])
# Python set does not maintain indexing that's why we can't able to access any item
# update item
# data_set2.update(9) # typeerror: int object is not iterable
... | true |
4c4beb3e71d405a3c427d55aee8c130e5f4fa851 | emilybisaga1/emilybisaga2.github.io | /Hws/wordcloud.py | 1,024 | 4.3125 | 4 | def generate_wordcloud(text):
'''
You can earn up to 10 points of extra credit by implementing this function,
but you are not required to implement this function if you do not want the extra credit.
To get the extra credit, this function should take as input a string
and save a file to your computer... | true |
3e44c4ef971a823812c72bf4a08a9a25b6dfbb56 | ore21/PRG105 | /average rainfall.py | 662 | 4.1875 | 4 | years = int(input("Please enter the number of years: "))
grand_total = 0
for year in range(0, years):
year_total = 0
print("Year " + str(year + 1))
for months in ("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec "):
rainfall_inch = float(input("Enter the inches of ra... | true |
34d3a22fc681d55be6c4d0358f960e943dfdcf0d | ore21/PRG105 | /calories by macronutrient.py | 1,026 | 4.1875 | 4 | """Calories by Macronutrient"""
fat_grams = float(input("enter a number of fat grams:"))
carbohydrate_grams = float(input("enter a number of carbohydrate grams:"))
protein_grams = float(input("enter a number of protein grams:"))
def calories_from_fat(fat_grams):
total = fat_grams * 9
print("calo... | true |
d4473972a201e825f635bf891f8763f128c48695 | kirankumar-7/python-mini-projects | /hangman.py | 496 | 4.125 | 4 | import random
print("Welcome to the hangman game ")
word_list=["python","java","programming","coding","interview","dsa","javascript","html","css","computer"]
chosen_word=random.choice(word_list)
#creating a empty list
display=[]
word_len=len(chosen_word)
for _ in range(word_len):
display += "_"
p... | true |
cbc1ae8e2cf208c50c6ea112b4b9802d1a4e2b8c | kirankumar-7/python-mini-projects | /lovecalculator.py | 1,172 | 4.125 | 4 | print("welcome to the love calculator! ")
name1=input("What is your name? ").lower()
name2=input("What is their name? ").lower()
combined_name=name1+name2
t=combined_name.count("t")
r=combined_name.count("r")
u=combined_name.count("u")
e=combined_name.count("e")
true =t+r+u+e ... | true |
f931a44604fa5cb283be4c7c904a7795aa38a03e | Gyanesh-Mahto/Practice-Python | /string/index_rindex.py | 1,716 | 4.53125 | 5 | # index() method is also used to find substring from main string from left to right(begin to end).
# It returs as follows:
# If substring is found then index() method returns index of first occurance of substring
# But if substring is not found in main string then index() will generate ValueError instead of -1 as compa... | true |
0b3776767151ffba5e60fcb171a332e586dcef53 | Gyanesh-Mahto/Practice-Python | /control_flow/if_elif_else.py | 327 | 4.28125 | 4 | '''
if-elif-else syntax:
if condition-1:
Action-1
elif condition-2:
Action-2
elif condition-3:
Action-3
-
-
-
else:
default action
'''
num=int(input("Please enter any number: "))
if num>0 and num%2==0:
print("Even")
elif num>0 and num%2!=0:
print("Odd")
else:
print('Number is negative or z... | false |
a85a63008d812d2ed0cc260ec38a209493227b60 | Gyanesh-Mahto/Practice-Python | /control_flow/biggest_smallest_num_3_input.py | 448 | 4.4375 | 4 | #WAP to find biggest of 3 given numbers
num1=int(input('Please enter your first number: '))
num2=int(input('Please enter your second number: '))
num3=int(input('Please enter your third number: '))
if num1>num2 and num1>num3:
print('{} is greater'.format(num1))
elif num2>num1 and num2>num3:
print('{} is greater... | true |
4717626688d17378fba8cb068262cc886b126904 | greenca/checkio | /three-points-circle.py | 1,529 | 4.4375 | 4 | # You should find the circle for three given points, such that the
# circle lies through these point and return the result as a string with
# the equation of the circle. In a Cartesian coordinate system (with an
# X and Y axis), the circle with central coordinates of (x0,y0) and
# radius of r can be described with the ... | true |
e2b49d23784a27bb16540c7b7665694dbc0f406b | greenca/checkio | /most-wanted-letter.py | 1,671 | 4.1875 | 4 | # You are given a text, which contains different english letters and
# punctuation symbols. You should find the most frequent letter in the
# text. The letter returned must be in lower case.
# While checking for the most wanted letter, casing does not matter, so
# for the purpose of your search, "A" == "a". Make sure y... | true |
17f9605c4bbde3c512d322f9fc0f52ac05b47b30 | angrajlatake/codeacademyprojects | /Scrabble dictonary project.py | 2,817 | 4.1875 | 4 | '''In this project, you will process some data from a group of friends playing scrabble. You will use dictionaries to organize players, words, and points.
There are many ways you can extend this project on your own if you finish and want to get more practice!'''
letters = ["A", "B", "C", "D", "E", "F", "G", "H", "I",... | true |
f9fd421e081da8c9617af08604ce70228a8318fa | aj112358/python_practice | /(1)_The_Python_Workbook/DICTIONARIES/unique_characters.py | 821 | 4.5625 | 5 | # This program determines the number of unique characters in a string.
# Created By: AJ Singh
# Date: Jan 8, 2021
from pprint import pprint
# Places characters of string into a dictionary to count them.
# @param string: String to count characters for.
# @return: Dictionary of character counts.
def check_unique(strin... | true |
f7116009a799a92e16f1434c4c5d7f30c26f8737 | aj112358/python_practice | /(1)_The_Python_Workbook/LISTS/infix_to_postfix.py | 1,751 | 4.25 | 4 | # This program converts a list of tokens representing a mathematical expression, and
# converts it from infix form to postfix form.
# Created By: AJ Singh
# Date: Jan 7, 2021
from tokenizing_strings import tokenize, identify_unary
from string_is_integer import is_integer
from operator_precedence import precedence
OPE... | true |
4a304cfabcd09a9e64f518ebe06c97de188c2321 | aj112358/python_practice | /(1)_The_Python_Workbook/FILES_EXCEPTIONS/letter_frequency.py | 948 | 4.3125 | 4 | # Exercise 154: Letter Frequency Analysis.
from string import ascii_uppercase
from string import punctuation
from string import digits
import sys
if len(sys.argv[1]) < 2:
print("Input file needed.")
quit()
def open_file():
try:
file = open(sys.argv[1], mode="r")
return file
except F... | true |
d150af4735c935c4007f9ed797656fd39b26650f | aj112358/python_practice | /(1)_The_Python_Workbook/FUNCTIONS/string_is_integer.py | 683 | 4.5 | 4 | # This program determines if a string is an integer, and takes the sign into account.
# Created By: AJ Singh
# Date: Jan 7, 2021
# Check if a string represents a valid integer
# @param num: String to check.
# @return: Boolean value.
def is_integer(num: str) -> bool:
"""Determine if a string represents a valid pos... | true |
6f112b3d3d079773fea42c67408b770b8b239cbc | aj112358/python_practice | /(1)_The_Python_Workbook/LISTS/proper_divisors.py | 739 | 4.625 | 5 | ### This program compute the list of proper divisors of an integer
# Created By: AJ Singh
# Date: Jan 6, 2021
from math import sqrt, floor
# This function computes the divisors of an integer
# @param n: Input to factor.
# @return: List of divisors.
def divisors(n: int) -> list:
"""Compute all the (positive) divi... | true |
ff2b2ad084e8ce4f0ffe6484ce87094f68b9db12 | aj112358/python_practice | /(1)_The_Python_Workbook/LISTS/evaluate_postfix_expr.py | 1,503 | 4.4375 | 4 | # This programs evaluates a basic mathematical expression, given via tokens in postfix form.
# Created By: AJ Singh
# Date: Jan 7, 2021
from tokenizing_strings import tokenize, identify_unary
from infix_to_postfix import to_postfix
OPERATORS = list("+-*/^")
# Evaluates a postfix expression, given the tokens.
# @par... | true |
01c9bb23ef18c66e2eb631571534669e073ae0c8 | oddduckden/lesson3 | /task1.py | 1,242 | 4.15625 | 4 | # 1. Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление. Числа запрашивать у
# пользователя, предусмотреть обработку ситуации деления на ноль.
def division_func():
'''
Функция деления двух введенных чисел первое на второе
:return: None
'''
while True:
... | false |
02974eec581d9a28f995a6b187f13bfd7a272664 | ricaenriquez/intro_to_ds | /project_3/other_linear_regressions/advanced_linear_regressions.py | 2,740 | 4.59375 | 5 | import numpy as np
import pandas as pd
import statsmodels.api as sm
"""
In this optional exercise, you should complete the function called
predictions(turnstile_weather). This function takes in our pandas
turnstile weather dataframe, and returns a set of predicted ridership values,
based on the other information in ... | true |
45362e23912a3f3fae4021f27f5983875cf64aaf | DonNinja/111-PROG-Assignment-5 | /max_int.py | 610 | 4.59375 | 5 | num_int = int(input("Input a number: ")) # Do not change this line
# Fill in the missing code
max_int = 0
while num_int > 0:
if num_int > max_int:
max_int = num_int
num_int = int(input("Input a number: "))
print("The maximum is", max_int) # Do not change this line
# First we have to take in nu... | true |
92fb6e42ffea61173e20c30d7541d68501156ef7 | cyber-holmes/temperature_conversion_python | /temp.py | 333 | 4.5 | 4 | #Goal:Convert the given temperature from Celsius to Farenheit.
#Step1:Take the user-input on temperature the user wish to convert.
cel= input("Enter your temperature in Celsius ")
#Step2:Calculate the conversion using formula (celsius*1.8)+32
far = (cel*1.8)+32
#Step3:Print the output.
print ("It is {} Farenheit".f... | true |
8f6ca9ea53f6cfad80afb24783e381e78e0c595d | Youngjun-Kim-02/ICS3U-Unit6-03-python | /smallest_number.py | 852 | 4.21875 | 4 | #!/usr/bin/env python3
# Created by: Youngjun Kim
# Created on: June 2021
# This program uses a list as a parameter
import random
def find_smallest_number(random_numbers):
Smallest_number = random_numbers[0]
for counter in random_numbers:
if Smallest_number > counter:
Smallest_number =... | true |
92beb7b2e2a8e8819ff0d48605a174b899a37b18 | paulthomas2107/TKinterStuff | /entry.py | 388 | 4.21875 | 4 | from tkinter import *
root = Tk()
e = Entry(root, width=50, bg="blue", fg="white", borderwidth=5)
e.pack()
e.insert(0, "Enter your name: ")
def myClick():
hello = "Hello " + e.get()
my_label = Label(root, text=hello)
my_label.pack()
myButton = Button(root, text="Enter name", padx=50, pady=50, command=... | true |
5b3e1e1e415cddbc0eccf6358731a28a31025bc9 | darren11992/think-Python-homework | /Chapter 9/Exercise9-3.py | 924 | 4.125 | 4 | """Write a function named avoids that takes a word and a string of
forbidden letters and returns True if the word doesn't use any of the
forbidden letters. Modify the program to prompt the user to enter a
string of forbidden letters and then print the number of words that
don't contain any of them. Can you find a c... | true |
1e015d5e59880d86ebf92721884242b31393bf0e | darren11992/think-Python-homework | /Chapter 7/exercise7-1.py | 1,058 | 4.21875 | 4 | """Copy the loop from "Square roots" on page 79 and encapsulate it
in a function called mysqrt that takes a as a parameter, chooses
a reasonable value of x, and returns an estimate of the square root
of a. To test it, write a function named "test_square_root that
prints a table like this:
First column: a number, a... | true |
2d5540b41a118e786295696f6914076900f3d2d8 | darren11992/think-Python-homework | /Chapter 10/Exercise 10-3.py | 406 | 4.125 | 4 | """Write a function called middle that takes a list and returns a
new list that contains all but the first and last elements.
For example:
>>> t = [1, 2, 3, 4]
>>> middle(t)
>>> [2, 3]"""
def middle(t):
new_t = t[:]
# new_t = t will use the same reference for both lists
del new_t[0]... | true |
4b6588e9bfbadac7f21f380fa94f1a7de79ad444 | darren11992/think-Python-homework | /Chapter 9/Exercise9-9.py | 2,279 | 4.15625 | 4 | """Here's another car talk Puzzler you can solve with a search;
"Recently I had a visit with my mum and we realised that the two
digits that make up my age reversed resulted in her age. For
example, if she's 73, I'm 37. We wondered how often this has
happened over the years but we got sidetracted with other top... | true |
0b6a86223916b8161c66054f5eb03afcbf301b4e | darren11992/think-Python-homework | /Chapter 8/notes8.py | 1,379 | 4.25 | 4 | """
- Strings are sequences of characters.
- The bracket operator allows you to select individual characters
in a string:
eg:
fruit = 'banana'
letter = fruit[2] --> 'n'
Note: string indexs begin at 0.
-The len() function returns the length of a string. The final index
of a string is always i... | true |
b6876e179285f7578c42538e73a0f5587fa46960 | chenxi-zhao/various_tools | /python_tools/_basic/dictionary.py | 1,208 | 4.125 | 4 | # coding=utf-8
__author__ = 'TracyZro'
# Python 字典(Dictionary)
# 访问字典里的值
mydict = {'Name': 'Zara', 'Age': 7, 'Class': 'First'}
print("dict['Name']: ", mydict['Name'])
print("dict['Age']: ", mydict['Age'])
# 修改字典
mydict['Age'] = 8 # update existing entry
mydict['School'] = "DPS School" # Add new entry
print('myd... | false |
53d4055fd07e0b4477fad07281d3c8af223e90d3 | yura702007/algorithms | /quick_sort.py | 453 | 4.15625 | 4 | def quick_sort(arr):
if len(arr) < 2:
return arr
pivot = arr[0]
left_arr, middle_arr, right_arr = [], [], []
for i in arr:
if i < pivot:
left_arr.append(i)
elif i == pivot:
middle_arr.append(i)
else:
right_arr.append(i)
return quick... | false |
018e5b31a3717d11a37460be83c42d97ff4b673b | Jagadeshwaran-D/Python_pattern_programs | /simple_reverse_pyramid.py | 291 | 4.25 | 4 | """ python program for simple reverse pyramid
* * * * *
* * * *
* * *
* *
*
"""
### get input from the user
row=int(input("enter the row"))
##logic for print the pattern
for i in range(row+1,0,-1):
for j in range(0,i-1):
print("* " ,end="")
print() | true |
f639317fbaab1d84ef7bbc939185c52ddeabd531 | AbilashC13/module1-practice-problems-infytq | /problem05.py | 715 | 4.15625 | 4 | #PF-Prac-5
'''
Write a python function which accepts a sentence and finds the number of letters and digits in the sentence.
It should return a list in which the first value should be letter count and second value should be digit count.
Ignore the spaces or any other special character in the sentence.
'''
def count_dig... | true |
75115dbfa45590ecebc885a7fcc2f6637ea5e281 | Midhun10/LuminarPython | /Luminar_Python/exceptionHandling/except.py | 451 | 4.21875 | 4 | num1=int(input("Enter num1"))
num2=int(input("Enter num2"))
# res=num1/num2#exception can be raised in this code.
# print(res)
try:
res=num1/num2
print(res)
except Exception as e:#Exception is a class in the
# print("exception occured")
print("Error:",e.args)
finally:
print("Printing finally")
# i... | true |
ae0c5498a64706c510bdad26b28d32c3b1ee121c | drewgoodman/Python-Exercises | /birthday_lookup.py | 1,305 | 4.53125 | 5 | # keep track of when our friend’s birthdays are, and be able to find that information based on their name. Create a dictionary (in your file) of names and birthdays. When you run your program it should ask the user to enter a name, and return the birthday of that person back to them. The interaction should look somethi... | true |
92faf865a1991fb85273660d92adfc06048808a3 | willgood1986/myweb | /pydir/listgen.py | 282 | 4.25 | 4 | # -*- coding: utf-8 -*-
print("List generate: [x for x in 'abc']")
print([ x + "&" + y for x in 'ABC' for y in '123'])
print("list-generator operates on list")
datas = {'a':1, 'b':2, 'c':3}
print("Get data[key, val] from dict use dict.items")
print([y+2 for x, y in datas.items()])
| false |
f941240d58c731e5307c76b1a36c01174a70fa62 | guilhermebaos/Other-Programs | /Modules/my_inputs/__init__.py | 2,256 | 4.28125 | 4 | # Manter Ordem Alfabética
def inputfloat(string='Escreva um número: ', error='ERRO! Escreva um número válido!\n', show_error=False,
change_commas=True, default=0):
"""
:param string: Input text
:param error: Error message for non-float input
:param show_error: Show what caused the error... | false |
cd379021d642213e5d3879485d53610283277e09 | robbyorsag/pands-problem-set | /solution-9.py | 360 | 4.3125 | 4 | # Solution to problem 9
# Open the file moby-dick.txt for reading and mark as "f"
with open('moby-dick.txt', 'r') as f:
count = 0 # set counter to zero
for line in f: # for every line in the file
count+=1 # count +1
if count % 2 == 0: # if the remainder is 0
print(line)
... | true |
89279b55447199014c2fb78fce1f538f09095cc0 | taisonmachado/Python | /Lista de Exercicios - Wiki_python/Estrutura de Decisao/18.py | 358 | 4.25 | 4 | #Faça um Programa que peça uma data no formato dd/mm/aaaa e determine se a mesma é uma data válida.)
data = input("Digite uma data no formato dd/mm/aaaa: ")
data = data.split('/')
dia = int(data[0])
mes = int(data[1])
ano = int(data[2])
if(dia>0 and dia<=31 and mes>0 and mes<=12 and ano>0):
print("Data válida")
... | false |
39de0b3527cff7a7638b6b0381781f92a63e1015 | taisonmachado/Python | /Lista de Exercicios - Wiki_python/Estrutura Sequencial/06.py | 242 | 4.15625 | 4 | # Faça um Programa que peça o raio de um círculo, calcule e mostre sua área.
import math
raio = int(input("Digite o raio do círculo: "))
area = math.pow(raio, 2) * math.pi
print("Area: ", area)
input("Pressione Enter para continuar") | false |
bfc4b237e97584616ff6ff0f25ba95fdb38852d2 | taisonmachado/Python | /Lista de Exercicios - Wiki_python/Estrutura de Repetição/10.py | 293 | 4.1875 | 4 | #Faça um programa que receba dois números inteiros e gere os números inteiros que estão no
#intervalo compreendido por eles.
print("Informe dois números: ")
num1 = int(input())
num2 = int(input())
print("\nIntervalo entre os dois números: ")
for i in range(num1+1, num2):
print(i) | false |
e35ad11469ddc5af286489ccb6724ee80113cac7 | 311210666/Taller-de-Herramientas-Computacionales | /Clases/Programas/Práctica/problema6.py | 302 | 4.15625 | 4 | #!usr/bin/python2.7
# -*- coding: utf-8 -*-
'''Implemente una función recursiva que calcule
n! = n * (n-1) * (n-2) * …* 2 * 1'''
def Factorial (n):
if n == 1:
return 1
else:
if n == 2:
return n * (n-1)
else:
return n * Factorial (n-1)
| false |
959982a60351e59343506654ebd3853590f9d82a | devsetgo/devsetgo_lib | /examples/cal_example.py | 681 | 4.15625 | 4 | # -*- coding: utf-8 -*-
from dsg_lib.calendar_functions import get_month, get_month_number
month_list: list = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
month_names: list = [
"january",
"february",
"march",
"april",
"may",
"june",
"july",
"august",
"september",
"october",
... | false |
e67a95bace31db0b3aed7329da33e8bccd2457e4 | evidawei/Hacktoberfest2021-2 | /Python/Queue using Stacks.py | 604 | 4.3125 | 4 | # Python3 program to implement Queue using
# two stacks with costly enQueue()
class Queue:
def __init__(self):
self.s1 = []
self.s2 = []
def enQueue(self, x):
while len(self.s1) != 0:
self.s2.append(self.s1[-1])
self.s1.pop()
self.s1.append(x)
while len(self.s2) != 0:
self.s1.append(self.s2[... | false |
f343e54fdbb35885b1e610287d556abcc5f70f5c | tsar0720/HW_python | /HW11.py | 1,218 | 4.34375 | 4 | """
Напишите функцию letters_range, которая ведет себя
похожим на range образом, однако в качестве start и
stop принимает не числа, а буквы латинского алфавита
(в качестве step принимает целое число) и возращает
не перечисление чисел, а список букв, начиная с
указанной в качестве start, до указанной в качестве
stop с ш... | false |
821a532855aac783305a4ef5147c85c0a94546aa | DobleRodriguez/Inteligencia-de-Negocio | /S01 - E01.py | 1,918 | 4.15625 | 4 | # To add a new cell, type '# %%'
# To add a new markdown cell, type '# %% [markdown]'
# %% [markdown]
# # Ejercicios del Seminario 1 (Introducción a Python)
#
# En este notebook se pide realizar un par de ejercicios sencillos para ir practicando Python.
# %% [markdown]
# ## Ejercicio 1
#
#
# Escriba una función _cal... | false |
f8024b9b4a567f1d38a0db933953e6273a305bb0 | britneh/Intro-Python-I | /src/03_modules.py | 961 | 4.25 | 4 | """
In this exercise, you'll be playing around with the sys module,
which allows you to access many system specific variables and
methods, and the os module, which gives you access to lower-
level operating system functionality.
"""
import sys
# See docs for the sys module: https://docs.python.org/3.7/library/sys.html... | true |
f7a7dbafab4f54888a363b34f2bf7e60b64056de | aishuse/luminarprojects | /two/inpulseOperator.py | 1,223 | 4.34375 | 4 | # list1 = [10,11,23,45]
# list2 = list1
#
# # print("2nd list : ",list2)
# # list1 += [1, 2, 3, 4]
# # print(list2)
# # print(list1)
# print("next")
# list1=list1+[1,2,3,4]
#
# print(list1)
# print(list2)
# Python code to demonstrate difference between
# Inplace and Normal operators in Immutable Targets
# importing o... | true |
c42869a5b6d2d2052c01b7305b35f59a03b2064a | YunJ1e/LearnPython | /DataStructure/Probability.py | 1,457 | 4.21875 | 4 | """
Updated: 2020/08/16
Author: Yunjie Wang
"""
# Use of certain library to achieve some probabilistic methods
import random
def shuffle(input_list):
"""
The function gives one of the permutations of the list randomly
As we know, the perfect shuffle algorithm will give one specific permutation with the probabili... | true |
24c9c43afea201cba04dc20b1cd6bef2ec32f71d | frclasso/python_examples_one | /name.py | 292 | 4.28125 | 4 | #!/usr/bin/env python3
import readline
def name():
"""Input first and last name, combine to one string and print"""
fname = input("Enter your first name: ")
lname = input("Enter your last name: ")
fullname = fname + " " + lname
print("You name is ", fullname)
name() | true |
5cf568d7b5301a8c37b94ebb8665448af21dbcc9 | RodrigoMSCruz/CursoEmVideo.com-Python | /Desafios/desafio060.py | 454 | 4.125 | 4 | # Programa que calcula o fatorial de um número inserido pelo usuário.
n = int(input('Digite o valor a ser calculado o fatorial: '))
i = n
fat = 1
while i != 0:
fat = fat * i
i = i - 1
# end-while
print('Resultado do fatorial de {} com while: {}.'.format(n, fat))
# Mesmo exercício, apenas usando a estrutura F... | false |
bc14c555b482300307a75b579782b09007e21bd0 | RodrigoMSCruz/CursoEmVideo.com-Python | /Desafios/desafio083.py | 520 | 4.25 | 4 | # Programa onde o usuário digite uma expressão qualquer que use parênteses. A aplicação deve
# analisar se a expressão passada está com os parênteses abertos e fechados na ordem correta.
abre = fecha = 0
expressao = str(input('Digite a expressão a ser analisada: '))
for c in expressao:
if c == '(':
abre =... | false |
4ff2e11f7cf8cd04dd5d98e70ccb7565dd219a1b | RodrigoMSCruz/CursoEmVideo.com-Python | /Desafios/desafio086.py | 426 | 4.5 | 4 | # Programa que declara uma matriz de dimensão 3×3 e preencha com valores lidos pelo teclado. No final, mostra
# a matriz na tela, com a formatação correta.
matriz = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
for y in range(0, 3):
for x in range(0, 3):
n = int(input(f'Digite o valor para a posição [{y , x}]: '))
... | false |
38540039331f7afd2f28b8b80a5bb2a33dca4c13 | RodrigoMSCruz/CursoEmVideo.com-Python | /Desafios/desafio018.py | 466 | 4.25 | 4 | #Programa que Lê um ângulo e exibe o seno, cosseno e tangente desse ângulo.
from math import sin, cos, tan, radians
angulo = float(input('Digite um ângulo: º'))
rad = radians(angulo) #Necessário converter para radianos, pois as funções sin(), cos() e tan() funcionam com radianos.
print('O ângulo {}, em radianos é {} ... | false |
eec120862b6318eeb401286f08c3b958207355d2 | RodrigoMSCruz/CursoEmVideo.com-Python | /Desafios/desafio033.py | 529 | 4.125 | 4 | # Pede para o usuário entrar com 3 valores e o programa informa qual é o menor e o maior deles.
n1 = int(input('Digite um valor inteiro para o primeiro número: '))
n2 = int(input('Digite um valor inteiro para o segundo número: '))
n3 = int(input('Digite um valor inteiro para o terceiro número: '))
seq = [n1, n2, n3] ... | false |
3352a7824e6e62b969d5507b9e6cb791b15216fc | JaygJr/Pie | /Bmi/Test/testlong.py | 2,081 | 4.28125 | 4 |
#!/usr/bin/env python3
"""This script will calculate BMI via height/weight input"""
import string
from time import sleep
from gpiozero import LED
# ToDo accept input for positive integers ONLY, and make it a function
# DONE INTERNALLY ONLY - ToDo change bmi height/weight calculations to a func
# ToDo change code ... | true |
5170c66b0a7fda701e0052543100577362e72f3a | BaerSenac/Curso_em_Video_Modulo | /Curso_em_video_Modulo2/condicoes_alinhadas/Exercicios/triangulos+.py | 297 | 4.125 | 4 | r1 = float(input("Digite um lado: "))
r2 = float(input("Digite um segundo lado: "))
r3 = float(input("Digite um terceiro lado: "))
if r1 < r2 + r3 and r2 < r1 + r3 and r3 < r1 + r2:
print("Os segmentos acima PODEM FORMAR UM TRIANGULO!")
else:
print("Os acima não PODEM FORMAR UM TRIANGULO!") | false |
eb5d06d370df3491e5144320bf670797bc56fc46 | SalihGezgin/meinarbeitsbereich | /python/coding-challenges/cc-005-create-phonebook/app.py | 1,717 | 4.1875 | 4 | def print_menu():
print("Welcome to the phonebook application.")
print('1. Find phone number.')
print('2. Insert a phone number.')
print('3. Delete a person from the phonebook.')
print('4. Terminate!')
print()
def find(name):
if name in phonebook:
print(phonebook[name])
else:
... | false |
64eb2ebc38fc4c2b5201dae4b75e61e97eda4fc2 | MouChakraborty/JISAssasins | /Question15.py | 277 | 4.25 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[2]:
#Program to find the value of x^(y+z) By Moumita Chakraborty
import math
x=int(input("Enter the value of x"))
y=int(input("Enter the value of y"))
z=int(input("Enter the value of z"))
a=y+z
b=pow(x,a)
print("The value is",b)
# In[ ]:
| true |
320e3160f26f2b52fe22825a9e676719bb31ac15 | MouChakraborty/JISAssasins | /Question16.py | 404 | 4.5625 | 5 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
#Question 16
##Write a Program to Accept character and display its
# Ascii value and its Next and Previous Character.
#chr() for ascii to char By Moumita Chakraborty
x= input("Enter the input :")
n= ord(x)
prev= n - 1
next= n + 1
a=chr(prev)
b=chr(next)
print(" ASCII va... | true |
b1ae07b29c5e5e39adb58970b8fdbc3a4508957e | atulzh7/IW-Academy-Python-Assignment | /python assignment ii/question_no_6.py | 244 | 4.21875 | 4 | """Searching name using for loop
"""
sample_list = ["Kushal", "John", "Bikash", "Paras", "Pradeep", "Diwash"]
print(sample_list)
for name in sample_list:
if name == 'John':
print("Found...")
else:
print("Not found...") | false |
24ed34ca93e72f8f56a0ec16e8e2e5733c40e768 | rchen00/Algorithms-in-Python | /string reverse recursive.py | 801 | 4.15625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 16 21:12:26 2021
@author: robert
"""
def string_reverse1(s):
if len(s) == 0:
return s
else:
return string_reverse1(s[1:]) + s[0]
s = "Robert"
print ("The original string is: ",end="")
print (s)
... | true |
b022fcf0e10ca9d637ccafa31a018a2523770c30 | optionalg/python-programming-lessons | /rock_paper_scissors.py | 2,520 | 4.1875 | 4 | # pylint: disable=C0103
# 2 players
# 3 possibles answers: rock, paper, scissors
# rock > scissors > paper > rock ...
# ask the players their name
# ------- loop start -------
# ask their choice
# check their choice (needs to be valid)
# find a way to hide the choice???? https://stackoverflow.com/questions/2084508/cl... | true |
fcc875501cf71d3fe510e1bcbb20ca9e3b8e2774 | optionalg/python-programming-lessons | /Students/temperature_wendy2.py | 776 | 4.125 | 4 | # Temperature conversion
def menu():
print("\nl. Celcius to Fahrenheit")
print("2. Fahrenheit to Celcius")
print("3. Exit")
return int(input("Enter a choice: "))
def toCelsius(f):
return int((f-32) / 1.8)
def toFahrenheit(c):
return int(c * 1.8 +32)
def main():
choice =... | false |
7be942bc1eed5186e5867bbb05d684dedecc67ba | ENAIKA/PasswordLocker | /user_test.py | 2,726 | 4.15625 | 4 | import unittest # Importing the unittest module
from user import User # Importing the user class
class TestUser(unittest.TestCase):
'''
Test class that defines test cases for the user class behaviours.
'''
def setUp(self):
'''
Set up method runs before each test cases.
'''
... | true |
244edeb9206d06f0b27d2dcc761bd43fadeb3748 | SoniaAmezcua/python_class | /ejercicio_01.py | 2,889 | 4.15625 | 4 | '''
Ejercicio 1
Construir un Script que permita generar una fila de 'Sudoku', es decir, una fila de 9 valores
con numeros del 1 al 9 y que ninguno de los valores se repitan y mostrar la fila.
Para comprobar que la fila esta bien construida, deberan calcular la sumatoria de la fila y debe dar como res... | false |
b429f034f7810ef4e4331ae80cb648710e8ff4ac | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_8/try_8.8.py | 961 | 4.53125 | 5 | #Done by Carlos Amaral in 29/06/2020
"""
Start with your program from Exercise 8-7. Write a while
loop that allows users to enter an album’s artist and title. Once you have that
information, call make_album() with the user’s input and print the dictionary
that’s created. Be sure to include a quit value in the while lo... | true |
40f000710dba311de1cfb53c3740df002537de25 | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_8/try_8.3.py | 728 | 4.34375 | 4 | #Done by Carlos Amaral in 28/06/2020
"""
Write a function called make_shirt() that accepts a size and the
text of a message that should be printed on the shirt. The function should print
a sentence summarizing the size of the shirt and the message printed on it.
Call the function once using positional arguments to mak... | true |
03741ecd81689dce53ca5f31115f635db5b2b3ee | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_3/try_3.10.py | 341 | 4.3125 | 4 | cities = ['Porto', 'Lisboa', 'Viseu', 'Vigo', 'Wien']
print(cities)
print(len(cities))
#Reverse alphabetical order
cities.sort(reverse=True)
print(cities)
#Sorting a list temporarily with the sorted() function
print("\nHere is the sorted list:")
print(sorted(cities))
#Printing a list in Reverse Order
print(cities)
... | true |
a330687c3ff041d17b9530c05c074555b284a919 | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_5/try_5.2.py | 1,259 | 4.1875 | 4 | #Done by Carlos Amaral in 17/06/2020
"""
5-2. More Conditional Tests: You don’t have to limit the number of tests you
create to ten. If you want to try more comparisons, write more tests and add
them to conditional_tests.py. Have at least one True and one False result for
each of the following:
• Tests for equality an... | true |
6f35e52ecc19b49821a12684fcc4bc77d2ad0257 | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_10/try_10.2/learn_C.py | 656 | 4.375 | 4 | #Done by Carlos Amaral in 11/07/2020
"""You can use the replace() method to replace any word in a
string with a different word. Here’s a quick example showing how to replace
'dog' with 'cat' in a sentence:
>>> message = "I really like dogs."
>>> message.replace('dog', 'cat')
'I really like cats.'
Read in each line f... | true |
d16f147994679c01cebbcab39ec9d80969a1f30a | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_6/try_6.2.py | 953 | 4.3125 | 4 | #Done by Carlos Amaral in 21/06/2020
"""
Use a dictionary to store people’s favorite numbers.
Think of five names, and use them as keys in your dictionary. Think of a favorite
number for each person, and store each as a value in your dictionary. Print
each person’s name and their favorite number. For even more fun, po... | true |
894bd27767bb90b0c1e66344b4e38ec462681c13 | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_5/try_5.3.py | 708 | 4.1875 | 4 | #Done by Carlos Amaral in 18/06/2020
"""
Imagine an alien was just shot down in a game. Create a
variable called alien_color and assign it a value of 'green' , 'yellow' , or 'red' .
• Write an if statement to test whether the alien’s color is green. If it is, print
a message that the player just earned 5 points.
• Wri... | true |
f9493f994afa60ee4ea4e5177eb87f2deb60d39a | charliealpha094/Python_Crash_Course_2nd_edition | /Chapter_11/try_11.1/city_functions.py | 812 | 4.25 | 4 | #Done by Carlos Amaral in 16/07/2020
"""
Write a function that accepts two parameters: a city name
and a country name. The function should return a single string of the form
City, Country , such as Santiago, Chile . Store the function in a module called
city _functions.py.
Create a file called test_cities.py that test... | true |
4fac06b757d902fbf633efd826c9854b429373d5 | premanshum/pythonWorks | /aFolder/miscDemo01.py | 639 | 4.125 | 4 | '''
This program prints the histogram for the list provided
We will solve this using list comprehension
List Comprehension => [expr(item) for item in iterable]
'''
def histogram ( items) :
[print(item,' : ', '* ' * item) for item in items]
#histogram ([3, 5, 2, 6, 9])
import socket
print([ip for ip... | false |
c2e0671c986eaeb5cbdad8c2b193a2f21617dc4c | rajeevbkn/fsdHub-mathDefs | /factorialNum.py | 371 | 4.40625 | 4 | # This snippet is to find factorial of a positive integer number.
n = int(input('Enter a positive integer number: '))
factorial = 1
if n < 0:
print('Factorial of a negative number is not possible.')
elif n == 0:
print('Factorial of 0 is 1.')
else:
for i in range(1, n+1):
factorial = factorial * i
... | true |
bd1fddbe81544186001b12fd84faf35b17f688bb | MariusArhaug/bicycleLocation | /highestProduct.py | 948 | 4.40625 | 4 | def highestProduct(listA):
length = len(listA)
if length < 3:
return "List is not big enough to find biggest product of 3 integers!"
listA.sort() #ascending order
#Check if a list only contains negative numbers
count = 0
for integer in listA:
if integer < 0:
count ... | true |
724078ce3c84dca14dada8889fc0c4828a63670a | RyanMullin13/Euler | /problem1.py | 400 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 5 13:58:41 2021
@author: ryan
"""
"""
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get
3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
ans = 0
for i ... | true |
7014468d396a9f3b4a8eb43a8f4f71d0d3e8004f | meenakshikathiresan3/sorting_algorithms | /insertion_sort/insertion_sort.py | 2,442 | 4.4375 | 4 | """
Python insertion sort implementation
20210920
ProjectFullStack
"""
import random
def insertion_sort(the_list):
# outer loop, we start at index 1 because we always assume the
# FIRST element in the_list is sorted. That is the basis of how
# insertion sort works
for i in range(1, len(the_list)):
... | true |
39302fda8f50d1fd6f9af28b537bca7396d8b20a | juanhuancapaza/PythonFinal | /Modulo 1/Problema1.py | 205 | 4.15625 | 4 |
# Ingresar el nombre de Emma
name = input('What is your name?')
print('Hello, {}'.format(name))
# Ingresar el nombre de Rodrigo
name = input('What is your name?')
print('Hello, {}'.format(name)) | false |
f965af6dd3aed580e083dd2040e2ea63fb6d5707 | GuilhermeZorzon/Project-Euler | /Problem6.py | 558 | 4.15625 | 4 | def sqr_sum_difference(num = 100):
''' (int/ ) -> int
Given num, finds the diference between the sum of all the squares of the numbers lower than num
and the square of the sum of these same numbers. Num is set to 100 if no value is passed
To use:
>>> sqr_sum_difference(2)
4
>>> sqr_... | true |
fe4f040f406b291c774ed2d9d7aaeb559e29bdb3 | Dheeraj809/dheeraj-b2 | /rev of string.py | 217 | 4.34375 | 4 | def reverse(s):
if len(s)==0:
return s
else:
return reverse(s[1:])+s[0]
s= input('enter the string')
print("The original string is:")
print(s)
print("The reversed string is:")
print(reverse(s)) | true |
5b0b9b23d2be5485525cddee396049237b17c1e4 | f034d21a/leetcode | /344.reverse_string.py | 753 | 4.25 | 4 | #! /usr/bin/python
# -*- coding: utf-8 -*-
"""
344. Reverse String
Write a function that takes a string as input and returns the string reversed.
Example:
Given s = "hello", return "olleh".
"""
class Solution(object):
def reverseString(self, s, method='a'):
_method = getattr(self, meth... | true |
ae8ee04522609dd86fb35bb7c38dacdb6d5c3ff9 | bethanyuo/DSA | /inputs.py | 401 | 4.40625 | 4 |
# user_input = input("What's the meaning of life? ") TypeError: '<' not supported between instances of 'str' and 'int'
user_input = int(input("What's the meaning of life? ")) # ==> Converts any input into an interger
if user_input == 42:
print("Correct answer!")
elif user_input < 42:
print("Sorry, but you e... | true |
6e671ccc023ecbcd163aecc57633d93a78d106e7 | chidoski/Python-Projects | /ex32.py | 1,040 | 4.625 | 5 | the_count = [1, 2, 3, 4, 5]
fruits = ['apples', 'oranges', 'pears', 'apriocts']
change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
#the first kind of for-loop goes through a list
for number in the_count:
print "This is count %d" % number
#same as above
for fruit in fruits:
print "These are the fruit %s" % fruit
#G... | true |
bcf489c63c2c3e3ee5af3c0ff9bfba06f1df49e3 | baliaga31/Python | /codecademy_exercices/Anti_vowels.py | 231 | 4.21875 | 4 | #!/usr/bin/python
def anti_vowel(text):
vowel_list = ["a","e","i","o","u","A","E","I","O","U"]
for n in text:
for n in vowel_list:
text = text.replace(n,"")
return text
print anti_vowel("Hey you")
| false |
64902aa98e5a99ae3401b8cd647936eb77f0202e | tsvielHuji/Intro2CSE-ex10 | /ship.py | 2,050 | 4.21875 | 4 | # Relevant Constants
SHIP_RADIUS = 1
SHIP_LIFE = 3
TURN_LEFT = "l"
TURN_RIGHT = "R"
VALID_MOVE_KEY = {TURN_RIGHT, TURN_LEFT}
class Ship:
"""Handles the methods and characteristics of a single Ship"""
def __init__(self, location, velocity, heading):
self.__location_x = location[0] # Locati... | true |
0a9dd5c965612b6907fb7c4acb2a2bd09a34a2ca | JiWenE/pycode | /函数部分/ex10.py | 739 | 4.25 | 4 |
def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ') # 以空格为分隔符将其转换为列表
return words
def sort_words(words):
"""Sorts the words."""
return sorted(words) # 排序
def print_first_word(words):
"""Prints the first word after popping it off."""
word = ... | true |
04c3436776290503c57409b445a8681e302a7bbc | shreyanse081/Some-Algorithms-coded-in-Python | /QuickSort.py | 1,137 | 4.15625 | 4 | """
QuickSort procedure for sorting an array.
Amir Zabet @ 05/04/2014
"""
import random
def Partition(a,p):
"""
Usage: (left,right) = Partition(array, pivot)
Partitions an array around a pivot such that the left elements <=
and the right elements >= the pivot value.
"""
pivot = a[p] ## the pivot value
... | true |
853c3a462260bc1e20f624ff80b784701ab4ba01 | ernestas-poskus/codeacademy | /Python/io_buffering.py | 820 | 4.125 | 4 | # PSA: Buffering Data
# We keep telling you that you always need to close your files after you're done writing to them. Here's why!
# During the I/O process, data are buffered: this means that they're held in a temporary location before being written to the file.
# Python doesn't flush the buffer—that is, write data ... | true |
c5987e266f3beb69d15ac78d21b0eada3f09527c | ernestas-poskus/codeacademy | /Python/int.py | 631 | 4.28125 | 4 | # int()'s Second Parameter
# Python has an int() function that you've seen a bit of already. It can turn non-integer input into an integer, like this:
# int("42")
==> 42
# What you might not know is that the int function actually has an optional second parameter.
# If given a string containing a number and th... | true |
8ad6c8bd609d664314df0a35cf3b81ded0b32250 | BeefAlmighty/CrackingCode | /ArraysStrings/Problem6.py | 989 | 4.15625 | 4 | # String compression: Compress a string on basis of character counts
# SO, e.g. aaabccaaaa --> a3b1c2a4. If the compressed string is not smaller
# than the original string, then the method should return the original string.
def compress(string):
letter_list = []
count_list = []
idx = 0
compressed = [... | true |
09d52ea26960f115db480abec979775cee4b7c99 | Redlinefox/Games_and_Challenges | /Guessing_Game/Guessing_Game_v2.py | 2,106 | 4.28125 | 4 | # Write a program that picks a random integer from 1 to 100, and has players guess the number.
# The rules are:
# If a player's guess is less than 1 or greater than 100, say "OUT OF BOUNDS"
# On a player's first turn, if their guess is within 10 of the number, return "WARM!"
# further than 10 away from the number, re... | true |
70342d4a95cfe0e7fcf26a480f166601865e75c2 | RubenTadeia/IASD | /2_Project/classes.py | 2,336 | 4.125 | 4 | class Tree():
""" Defines tree class """
def __init__(self, root):
if isinstance(root, tuple):
if len(root) == 2:
self.data = root[0]
self.left = Tree(root[1])
self.right = None
elif len(root) == 3:
self.data = r... | false |
6264b6239d29e1aee3a9b7139ffe1c93d549d980 | alialavia/python-workshop-1 | /sixth.py | 1,671 | 4.375 | 4 | """
To evaluate the good or bad score of a tweet, we count the number of good and
bad words in it.
if a word is good, increase the value of good_words by one
else if a word is bad, increase the value of bad_words by one
if good_words > bad_words then it's a good tweet otherwise it's a bad tweet
"""
import json
import... | true |
cc7ef88686c8d373fd39688118340cda0064312d | brlala/Educative-Grokking-Coding-Exercise | /03. Pattern Two Pointer/7 Dutch National Flag Problem (medium).py | 932 | 4.3125 | 4 | # Problem Statement
# Given an array containing 0s, 1s and 2s, sort the array in-place. You should treat numbers of the array as objects,
# hence, we can’t count 0s, 1s, and 2s to recreate the array.
#
# The flag of the Netherlands consists of three colors: red, white and blue; and since our input array also consists
#... | true |
8a9475e083e978b40b6e164e6ff65af999ce569e | brlala/Educative-Grokking-Coding-Exercise | /11. Pattern Subsets/3. Permutations (medium).py | 862 | 4.1875 | 4 | # Problem Statement
# Given a set of distinct numbers, find all of its permutations.
def find_permutations(nums):
"""
Time:
Space:
"""
result = []
find_permutations_recursive(nums, 0, [], result)
return result
def find_permutations_recursive(nums, index, current_permutation, result):
... | true |
a6dbf81217f5306e17a270d2863d00168d42f31e | brlala/Educative-Grokking-Coding-Exercise | /04. Fast Slow pointers/2 Start of LinkedList Cycle (medium).py | 1,784 | 4.15625 | 4 | # Problem Statement
# Given the head of a Singly LinkedList, write a function to determine if the LinkedList has a cycle in it or not.
from __future__ import annotations
class Node:
def __init__(self, value, next: Node=None):
self.value = value
self.next = next
def has_cycle(head: Node):
"""... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.