text
stringlengths
5
121k
hungry = input("are you hungy?") if hungry =="yes": print("eat something") else: print("okay")
from tkinter import* import tkinter.messagebox def beenClicked(): radioValue = relStatus.get() tkinter.messagebox.showinfo("you clicked", radioValue) return def changeLabel(): name= "Thanks for the click " + yourName.get() labelText.set(name) yourName.delete(0,END) yourName.inser...
import threading import time class Hilo(threading.Thread): """ El hilo dura tanto como dure el main(). El stdout y stderr (print y errores) es es mismo que el main() """ def __init__(self): threading.Thread.__init__(self) self.setDaemon(True) self.contador_segundos = 0 ...
import csv import re import collections import pandas as pd def analyse_data(filename): with open('./' + filename, newline='') as data: reader = csv.reader(data, delimiter='"') for row in reader: if len(row) > 2: salary_items = re.findall(r'\d+.\d+', row[1]) ...
print("Calculator(Addition,Subtraction,Multiplication and Division)") No1=input("Enter First value:") No1= eval(No1) No2= input("Enter Second value:") No2= eval(No2) Sum= No1+No2 print (" Sum of both the values=",Sum) Diff= No1-No2 print("Difference of both values=",Diff) prod= No1*No2 print("Product of both the values...
import math import cv2 import numpy as np from matplotlib import pyplot as plt import time import sys import auxiliar as aux def encontra_circulo(img, codigo_cor): hsv_1, hsv_2 = aux.ranges(codigo_cor) hsv = cv2.cvtColor(img , cv2.COLOR_BGR2HSV) gray = cv2.cvtColor(img , cv2.COLOR_BGR...
import requests apiKey = "AIzaSyBdHvCMgUN-3Oy7HdkzW3AguKBDpuodSYw" url = "https://maps.googleapis.com/maps/api/geocode/json" location = input("Entery an address or city: \n") params = {'address':location, 'key':apiKey} response = requests.get(url =url, params = params) data = response.json() if data['status'...
class NMay: def __init__(self): pass def NM(self): num1 = int(input("Ingrese el primer número: ")) num2 = int(input("Ingrese el segundo número: ")) num3 = int(input("Ingrese el tercer número: ")) if num1 > num2 and num1 > num3: print("El número mayor e...
from enum import Enum class Automaton: """ An automaton has three types of states: `acc`, `dead`, normal. For a run to be accepted, it should satisfy: G(!dead) & GF(acc) Thus, in the automaton `dead` states has the property that they are `trap` states. If there are no `acc` states, acc is se...
def is_palindrome(word): word_len = len(word) for i in range(word_len // 2): if word[i] != word[word_len - i - 1]: return False return True print(is_palindrome('level')) print(is_palindrome('levels'))
def countStaircases(N): memo = [[0 for x in range(N + 5)] for y in range(N + 5)] for i in range(N + 1): for j in range (N + 1): memo[i][j] = 0 memo[3][2] = memo[4][2] = 1 for i in range (5, N + 1) : for j in range (2, i + 1) : if (j == 2) : memo[i][j] = memo[i - j][j] + 1 else...
line1 = input() line2 = input() if str.lower(line1) == str.lower(line2): print(0) elif str.lower(line1) > str.lower(line2): print(1) else: print(-1)
""" An expression is called prefix , if the operator appears in the expression before the operands. (operator operand operand) An expression is called postfix , if the operator appears in the expression after the operands . (operand operand operator) The program below accepts an expression in prefix and outputs the cor...
""" Program to calculate sum of linked list. In the sum_ll function we traversed through all the functions of the linked list and calculate the sum of every data element of every node in the linked list. """ class Node: def __init__(self, data): self.data = data self.next = None class Linke...
""" Introduction: Two pointer technique is an optimization technique which is a really clever way of using brute-force to search for a particular pattern in a sorted list. Purpose: The code segment below solves the Three Sum Problem. We have to find a triplet out of the given li...
''' The sieve of Eratosthenes is an algorithm for finding all prime numbers up to any given limit. It is computationally highly efficient algorithm. ''' def sieve_of_eratosthenes(n): sieve = [True for i in range(n + 1)] p = 2 while p ** 2 <= n: if sieve[p]: i = p * p whil...
'''' This is the simple python code for finding the roots of quadratic equation. Approach : Enter the values of a,b,c of the quadratic equation of the form (ax^2 bx + c ) the function quadraticRoots will calculate the Discriminant , if D is greater than 0 then it will find the roots and print them otherwise it will ...
''' By using the double dabble method, append the remainder to the list and divide the number by 2 till it is not equal to zero ''' def DecimalToBinary(num): if num == 0: print('0000') return else: binary = [] while num != 0: rem = num % 2 binary.app...
""" When given a list of integers, we have to find the pair of adjacent elements that have the largest product and return that product. """ def MaxAdjacentProduct(intList): max = intList[0]*intList[1] a = 0 b = 1 for i in range(1, len(intList) - 1): if(intList[i]*intList[i+1] > max): ...
''' A program to remove the kth index from a string and print the remaining string.In case the value of k is greater than length of string then return the complete string as it is. ''' def main(): s=input("enter a string") k=int(input("enter the index")) l=len(s) if(k>l): print(s) ...
""" 给定一个数组 nums,编写一个函数将所有 0 移动到数组的末尾,同时保持非零元素的相对顺序。 示例: 输入: [0,1,0,3,12] 输出: [1,3,12,0,0] 说明: 必须在原数组上操作,不能拷贝额外的数组。 尽量减少操作次数。 """ class Solution: @staticmethod def moveZeroes(arr): """ 移动0 :type arr: object """ length = len(arr) j = 0 for i in r...
""" 给定一个整数数组 nums 和一个目标值 target,请你在该数组中找出和为目标值的那 两个 整数,并返回他们的数组下标。 你可以假设每种输入只会对应一个答案。但是,你不能重复利用这个数组中同样的元素。 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] """ class Solution: @staticmethod def twoSum(arr, target): """ 两数之和 使用字典结构 ...
x = 4 def add(x): print(x + 2) add(2)
import speech_recognition as sr AUDIO_FILE = ("sample.wav") r=sr.Recognition() with sr.AudioFile(AUDIO_FILE) as source: audio=r.record(source) try: print("audio file contains "+r.recognize_google(audio)) except sr.UnknownValueError : print("Google Speech Recognition could not understand audio") except...
num1 = input("Enter Number1: ") num2 = input("Enter Number2: ") result = float(num1) + float(num2) print(result)
from tkinter import * from tkinter import Label, Tk from time import strftime root=Tk() root.title("SAACAD") root.geometry("350x150") root.resizable(0,0) text_font=("ds-digital",50) background = "#f2e750" foreground= "#363529" border_width = 25 def time_clock(): string= strftime("%H:%M:%S") ...
def move_zeros_to_left(A): if len(A) < 1: return lengthA = len(A) write = lengthA - 1 read = lengthA - 1 while(read >= 0): if A[read] != 0: A[write] = A[read] write -= 1 read -= 1 while(write >= 0): A[write]=0; write-=1 v = [1, 10, 20, 0, 59, 63, 0, 88, 0] print("Ori...
class Account(): ''' create an account with account ower and initial money, capable of adding removing (conditional) from the account ''' def __init__(self, name, amount=0): self.owner = name self.amount = amount def deposit(self, add_amount): self.amount += add_amount return f'Deposit Accepted' def...
def func_compute(num): return lambda x : x * num result = func_compute(2) print("Double the number =", result(30))
def is_prime(N): if N<2: return False for i in range (2,N//2+1): if N%i==0: return False return True LB=int(input("Enter lower bound:")) UB=int(input("Enter upper bound:")) for i in range(LB,UB+1): if is_prime(i): print(i)
def fibo(n): if n <= 1: return n else: return(fibo(n-1) + fibo(n-2)) num = int(input("Enter the number")) if num <= 0: print("Cannot find fibonacci") else: print("Fibonacci series:") for i in range(num): print(fibo(i))
units=int(input("Enter the number of units:")) if units>=1 and units<=500: rate=6 elif units>=501 and units<=1000: rate=8 elif units>1000: rate=12 amount=units*rate if amount<50: amount=50 print(f"Units used:{units},Bill amount:{amount}")
def showInfo(student_dict): for key,value in student_dict.items(): print(f"{key}:{value}") student_dict={"ncet-ec01":"rajesh","ncet-ec02":"mahesh"} showInfo(student_dict)
def binarysearch(lst,key): l=0 h=len(lst)-1 while l<=h: mid=(l+h)//2 if lst[mid]==key: return mid elif key>lst[mid]: l=mid+1 else: h=mid-1 return -1 ele=20 res=binarysearch([1,2,3,4,5,6,7,8],ele) if res==-1: print(f...
print("Python basics - all in 1") myInt=7 print(f'Integer value stored on myInt is : {myInt}') myFloat1=7.0 print(myFloat1) myFloat2=float(7) print(myFloat2)
class House: def __init__(self, beds, price, date=None): self.date = date self.price = price self.beds = beds house = House(3, 102000) print(house.price) house.other = "New!" print(house.other) print(house.__dict__) house2 = House(5, 104000) print(house2.__dict__) print(id(house2.__dic...
from creature import Creature from room import Room def main(): print_header() room = build_rooms() play(room) def print_header(): print("*" * 80) print(" Welcome to the dungeon") print(" Where dragons come to play") with open('logo.txt') as fin: text = fin.read() pr...
def find_numbers(nums, test): lst = list() for i in nums: if test(i): lst.append(i) return lst result = find_numbers([1, 2, 3, 8, 3, 2, 87, 54, 55, 88, -2, -10], lambda n: n % 2 == 0) print(result) result.sort() print(result) result.sort(key=lambda v: a...
from typing import Collection, Iterable, List, Sized, Tuple, Union import readline def lcs(s1: str, s2: str, len1: int, len2: int) -> int: """Longest Common Subsequence using recursive method""" if 0 in (len1, len2): return 0 elif s1[len1 - 1] == s2[len2 - 1]: return 1 + lcs(s1, s2, len1...
li=['physics', 'chemistry', 1997, 2000] list3 = ["a", "b", "c", "d"] print(li[1]) print(li) print(li[:2]) print(li*2) l=li+list3 print(l) li[2]='physics' print(li) a=1997 print(a in li) print(len(li)) print(max(list3)) print(min(list3)) list3=list3+["e","f"] print(list3) tuple1=(1,2,3,4,5) ...
''' Created on 22 Sep 2017 @author: Christos Tsotskas ''' import unittest import json import xmlrunner from FizzBuzzer import FizzBuzzer class testFizzBuzzer(unittest.TestCase): def setUp(self): self.FizzBuzzer = FizzBuzzer() def tearDown(self): pass def test_...
fname=input("Enter file name : ") try: fh=open(fname) except: print("WRONG FILE") exit() count=0 total=0 for line in fh: line=line.rstrip() if not line.startswith('X-DSPAM-Confidence'): continue count=count+1 num=float(line[19:]) total=total+num pr...
import time import threading class Value: def __init__(self, value): self.value = value def deposit(balance, lock): for i in range(100): time.sleep(0.01) lock.acquire() balance.value += 1 lock.release() def withdraw(balance, lock): for i in range(100): t...
import pickle from linked_lists import LinkedList pickle_in = open('dict.pickle', 'rb') example_dict = pickle.load(pickle_in) pickle_in.close() my_list = LinkedList(2, 3, 4, 5, "s", example_dict) with open('my_list.pickle', 'wb') as wf: pickle.dump(my_list, wf)
import random from collections import deque class Jugador: def __init__(self, id): self.id = id self.habilidad = random.uniform(1, 10) self.jugados = 0 def win_vs(self, oponent): p = random.choice([True, False]) if self.habilidad > oponent.habilidad and p: ...
string = "aaaabbbccaaa" def compress(string): compressed = "" character = string[0] count = 1 for i in range(1,len(string)): if string[i] == character: count += 1 else: compressed += str(count)+character character = string[i] count = 1 compressed += str(count)+character return compressed print...
import pandas as pd q_df = pd.DataFrame([['male', 'teacher'], ['male', 'engineer'], ['female', None], ['female', 'engineer']],columns=['Sex','Profession']) q_df = q_df.fillna('others') a = pd.get_dummies(q_df[['Profession']]) q_df = pd.concat([q_df, a], axis=1) print(q_df)
import sys KEY = b'\x7b\x36\x14\xf6\xb3\x2a\x4d\x14\x19' SECRET = b'\x13\x59\x7a\x93\xca\x49\x22\x79\x7b' def authenticate(password): ''' Authenticates the user by checking the given password ''' password = password.encode() if len(password) != len(SECRET): return False ...
class Agent(): """ Implements the interface for an agent """ def __init__(self,env): """ Constructor for the agent class Args: env: a reference to an environment """ self.env = env def act(self): """ Defines the agent action ...
from graphics import * beep = 5 def main(): print( beep ) win = GraphWin("My Circle", 500, 500) c = Circle(Point(50,50), 10) c.setFill('blue') x = 10 y = 10 while True: x += 5 y += 5 j = c j.undraw() c = Circle(Point(x,y), 10) ...
a = 10 def variables(): a = 9 print("in function a:", a) variables() print("outside function a:", a) print("---------------------------------") def variables2(): global a a = 15 print("a in 2nd function:", a) variables2() print("a outside funct...
nums = [5,6,2,9,8,7,10,12,5] evens = list(filter(lambda n:n%2==0,nums)) print("filtered values: ",evens) changevalue = list(map(lambda n:n+1,evens)) print("changed values: ",changevalue)
import load_four_words_graph as four_words import load_345_words_graph as words_345 import word_chain_finder as finder def main(): graph_4_words = four_words.load_graph() graph_345_words = words_345.load_graph() while True: chain_opt = raw_input("Enter 1 for 4-words chain or 2 for 345-wor...
import string def main(): fhand = open('shakes.txt') counts = dict() for line in fhand: line = line.translate(string.punctuation) line = line.lower() line = line.replace('+',' ') words = line.split() for word in words: if word not...
class redisQ(object): """This class defines operations with redis queue which is used to store all remote ip addresses sniffed from requests""" def __init__(self, conn, qname=None): self.conn = conn if qname is None: qname = "redis:Q" self.queue = qname def push(s...
x = 10 y = 20 temp = x x = y y = temp print(x,y) import time start_time = time.time() x = 10 y = 20 temp = x x = y y = temp print(x,y) end_time = time.time() total_time = end_time - start_time print("Execution time is :",total_time)
''' Vikas Bhat Same Tree Type: Tree Time Complexity: O(n) Space Complexity: O(1) ''' class TreeNode: def __init__(self,val=0,left=None,right=None): self.left=left self.right=right self.val=val class main: def sameTree(self,root1,root2): if root1 and not root2: ...
''' Vikas Bhat Product of Array Except Self Time Complexity : O(n) Space Complexity: O(n) ''' class main: def productExceptSelf(self,nums): res = [1] left = 1 for i in range(len(nums) - 1, 0, -1): res.append(res[-1] * nums[i]) res=res[::-1] for j in range(0...
''' Vikas Bhat Container With Most Water Time Complexity: O(n) Sapce Complexity: O(1) ''' class main: def maxArea(self,height): area=1 s=0 e=len(height)-1 while s<e: area= max(area,(e-s)*min(height[s],height[e])) if height[s]<=height[e]: ...
import collections class AverageAccumulator: def __init__(self, maxsize): self.maxsize = maxsize self.samples = collections.deque() self.sum = 0 self.average = None def append(self, value): self.samples.append(value) self.sum += value if (len(self.sampl...
''' https://leetcode.com/problems/maximum-area-of-a-piece-of-cake-after-horizontal-and-vertical-cuts/ Given a rectangular cake with height h and width w, and two arrays of integers horizontalCuts and verticalCuts where horizontalCuts[i] is the distance from the top of the rectangular cake to the ith horizontal cut an...
''' 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 hanging the order of the remaining elements. For example, [3,6,2,7] is a subsequence of the array [0,3,1,6,2,2,7]. Cou...
''' Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Input: strs = ["eat","tea","tan","ate","nat","bat"] Output: [["...
'''Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nodes itself may be changed. ''' class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: ...
''' https://leetcode.com/problems/decode-ways/ A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there ma...
''' Given an array of non-negative integers nums, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. You can assume that you can always reach the last index. s...
''' Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Input: intervals = [[1,2],[3,5],[6,7],[8,10],[12,16]], newInterval = [4,8] Output: [[1,2],[3,10],[12,16]] Explanation: Bec...
''' Given the root of a binary search tree, and an integer k, return the kth (1-indexed) smallest element in the tree. Input: root = [5,3,6,2,4,null,null,1], k = 3 Output: 3 ''' class Solution: def kthSmallest(self, root, k): return self.in_order(root, k, False, None)[2] def in_order(self,...
''' You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. Return the maximum profit you can achieve from this transaction. If you cannot achieve...
'''Find all unique substrings containing distinct characters of length k given a string s containing only lowercase alphabet characters. Input: s = xabxcd, k = 4 Output: ["abxc", "bxcd"] Explanation: The substrings are xabx, abxc, and bxcd. However x repeats in the xabx, so it is not a valid substring of a distinct cha...
''' You want to schedule a list of jobs in d days. Jobs are dependent (i.e To work on the i-th job, you have to finish all the jobs j where 0 <= j < i). You have to finish at least one task every day. The difficulty of a job schedule is the sum of difficulties of each day of the d days. The difficulty of a day is the...
''' Your team is trying to understand customer shopping patterns and offer items that are regularly bought together to new customers. Each item that has been bought together can be represented as an undirected graph where edges join often bundled products. A group of n products is uniquely numbered from 1 of product_no...
print('------ Q 6 ------') lines = [] while True: line = input('linea: ') if line: lines.append(line.upper()) else: break for line in lines: print(line)
"""Módulo que se encarga de gestionar los mensajeros""" from csv import DictReader, DictWriter from os import write from os.path import join from app import app def get_deliveries(): with open( join(app.root_path, "data", "delivery.csv"), newline="" ) as csv_file: reader = DictReader(csv_file...
unsorted_list = ["a", "d", "c", "e", "b", "f", "h", "g"] def bubble_sort(unsorted_list): list_sorted = False length = len(unsorted_list) - 1 while not list_sorted: list_sorted = True for num in range(length): if unsorted_list[num] > unsorted_list[num+1]: ...
import turtle import math bob = turtle.Turtle() print(bob) l = 100 a = 120 b = 60 for i in range (6): for i in range(3): bob.fd(l) bob.rt(a) bob.rt(b)
import turtle import math bob = turtle.Turtle() print(bob) def polyline(t, n, length, angle): for i in range(n): t.fd(length) t.lt(angle) def arc(t, angle, pedal): radius = 200 arc_length = 2*math.pi*radius*angle/360 n = 50 step_length = arc_length/n step_angle = angle/n outer_angle = 180-angle for i in r...
def isState(param, states, capital_cities): if param in states: return getCapitalOfState(param, states, capital_cities) def isCapital(param, states, capital_cities): if param in capital_cities.values(): return getStateOfCapital(param, states, capital_cities) def getStateOfCapital(param, states, capital_cities)...
import turtle as t t.hideturtle() def circle(k): for _ in range(50): t.forward(k) t.left(36 / 5) def halfcircle(k): for _ in range(25): t.forward(k) t.right(36 / 5) t.shape('turtle') t.begin_fill() circle(7) t.color('yellow') t.end_fill() t.color('black') t.penup() t.goto(-...
import turtle as t import random t.speed(0) t.shape('circle') while True: t.forward(25 * random.random()) t.right(360 * random.random())
class Persona: nombre = "" apellido = "" edad = 0 nacionalidad = "" sexo = "" def __init__(self, nombre="NA", apellido="NA", edad="NA", nacionalidad="mexicano", sexo=""): self.nombre = nombre self.apellido = apellido self.edad = edad self.nacionalidad = nacion...
a = int(input()) b = int(input()) h = int(input()) if h < a: print('Deficiency') else: if h > b: print('Excess') else: print('Normal')
def print_to_txt(file_content, project_name, content_description, save_to_project_dir = False): import os from tabulate import tabulate output_file_name = project_name + '_' + content_description + '.txt' if save_to_project_dir == False: with open(output_file_name, "w") as text_file: ...
import sys class Node: def __init__(self, value): self.value = value self.char = None self.left_child = None self.right_child = None self.left_code = None self.right_code = None def set_value(self, value): self.value = value def get_value(self): ...
""" def sum_array_index(array, index): # Base Cases if len(array) - 1 == index: return array[index] return array[index] + sum_array_index(array, index + 1) arr = [1, 2, 3, 4] print(sum_array_index(arr, 0)) """ """ def recursion(listy, num): if len(listy) == 0: print('False') r...
import pygame from math import * class Post: def __init__(self, screen, x, y): self.win = screen self.x = x self.y = y self.dx = 0 self.dy = 0 self.radius = 16 self.gravity = .8 def tick(self): self.x += self.dx self.y += self.dy ...
from typing import Union, Sequence from itertools import islice def stairway_path(stairway: Sequence[Union[float, int]]) -> Union[float, int]: """ Calculate min cost of getting to the top of stairway if agent can go on next or through one step. :param stairway: list of ints, where each int is a cost of ap...
from typing import Sequence, Optional def binary_search(elem: int, arr: Sequence) -> Optional[int]: """ Performs binary search of given element inside of array :param elem: element to be found :param arr: array where element is to be found :return: Index of element if it's presented in the arr, N...
""" ------------------------------------------------------------------------------- Name: problem2.py Purpose: To check if the inputted sides form a triangle. Author: Schwarenberg.M Created: 23/02/2021 ------------------------------------------------------------------------------ """ print("Welcome to the Triangle C...
from pathlib import Path cwd = Path.cwd() print(cwd) new_file = Path.joinpath(cwd,'new_file.txt') print(ne...
""" Created on Tue Jan 7 22:55:22 2020 https://projecteuler.net/problem=5 @author: nigel """ dividend = 148842440 divisorSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 } divisorSet = { 20, 19, 18, 17, 16, 15, 14, 13, 12, 11 } quotientSum = 0 solved = 0 while solved == 0: for divisor in divisorSet: quoti...
""" Created on Mon Jan 6 21:46:26 2020 https://projecteuler.net/problem=2 @author: nigel """ a, b = 0, 1 total = 0 while a < 4000000: a, b = b, a + b print("b = ", b) if b % 2 == 0: total += b print("total = ", total)
first_dna, second_dna, mutation = input(''), input(''), 0 for i in range ( len (first_dna) ): if first_dna[i] != second_dna[i]: mutation += 1 print(mutation)
''' The sum of the squares of the first ten natural numbers is, 12 + 22 + ... + 102 = 385 The square of the sum of the first ten natural numbers is, (1 + 2 + ... + 10)2 = 552 = 3025 Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640. Fi...
''' This is to demonstrate the usage of decorators ''' import time import math def decorator_timer(func): def timer_function(*args, **kwargs): print('Inner function started') begin_time = time.time() print(begin_time) func(*args, **kwargs) time.sleep(1) end_t...
''' This is to demonstrate the usage of conditional operators ''' temperature = input('Enter the temperature:') if int(temperature) > 30: print('This is a hot day') elif int(temperature) < 5: print('This is a cold day') else: print('This is a pleasant day')
''' This is an example program for gussing a number using while loop ''' secret_number = 9 guess_count = 0 guess_limit = 3 while guess_count < guess_limit: guess_number = int(input('Guess a number: ')) guess_count += 1 if guess_number == secret_number: print('You guessed it right. You Win!!!') ...
from libs.utils import utils list = [1, 5, 9, 3, 2, 8] largest = utils() largest_num_in_list = largest.find_max(list) print(largest_num_in_list)
''' This program is to take input in KGs & display the weight in pounds ''' weight_kg = input('Enter your weight in Kilograms:') weight_lb = 2.2 * float(weight_kg) print('You weight is '+str(weight_lb)+' pounds')
def compress(s1: str) -> str: s2 = "" index = 0 tam = len(s1) counter = 1 while index <= tam - 1: if index > 0: if index == tam - 1: if s1[index] == s1[index - 1]: counter += 1 s2 = s2 + s1[index] + str(counter) ...