text
stringlengths
37
1.41M
#!/usr/bin/env python # # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # # Jiao Lin # California Institute of Technology # (C) 2005 All Rights Reserved All Rights Reserved # # {LicenseText} # # ~~~~~~~~~~~~~~~~~~~~~~~...
""" Working with dictionaries in python https://github.com/flaberenne/python3rep/textManipulation.py Author:flaberenne """ #Building a dictionary from 2 lists, the 1st one define the keys, the 2nd the values a=['en','fr','br','es'] b=['Hello','Bonjour',"Bom dia","Buenos dias"] dictionary={i:j for (i,j) in zip(a,b) } p...
def vowels(x): for i in range(len(y)) : if y[i] in h: print(y[i]) x=input("Insert any word : ") y=x.lower() h=['a','e','i','o','u'] i=0 vowels(x)
# -*- coding: UTF-8 -*- # 输出 Python 的每个字母 for letter in 'Python': if letter == 'h': pass print ("这是 pass 块") print ("当前字母 :", letter) print ("Good bye!") ''' 当前字母 : P 当前字母 : y 当前字母 : t 这是 pass 块 当前字母 : h 当前字母 : o 当前字母 : n Good bye! '''
import random from common.city import City def generate_random_cities(count=100): """ :type count: int :rtype: list[] """ cities = [] for number in xrange(0, count): x = random.uniform(-100, 100) y = random.uniform(-100, 100) cities.append(City(number, x, y)) retur...
class City(object): def __init__(self, number, x, y): """ :type number: int :type x: float :type y: float """ self.number = number self.x = x self.y = y def __str__(self): return "City #{0} [{1:.2f}; {2:.2f}]".format(self.number, self.x, s...
#!/usr/bin/env python import sys """Module for reading command line arguments Loosely follows the POSIX.1-2017 guidelines: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap12.html The command line arguments should consist of options, option-arguments, operands and a special argument -- Options have...
from question1 import * import datetime from PIL import Image import re # testing basic class functions c = Content('Example', 'This is a test', 'James', 2014, 3, 1) p = Picture('Example', 'This is a test', 'James', 2014, 3, 1, None) a = Article('Example', 'This is a test', 'James', 2014, 3, 5, 'fake_image.txt') c.sh...
# Basics of randomization ''' One of the things that makes games replayable is the pseudo-random nature of random numbers- in physical games that's easily done with dice. ''' import random # How many sides on the dice do we want? 6, 8, 10, 12, 20 and 100 are normal SIDES = 6 # We want a random intenger, meani...
""" The __init__.py serves double duty: it will contain the application factory, and it tells Python that the flaskr directory should be treated as a package. """ import os from flask import Flask """ create_app is the application factory function. You’ll add to it later in the tutorial, but it already does a lot. ""...
import array_stack stack = array_stack.ArrayStack() # input_file = open("input.txt", "r") input_file = "4 6 + 13 11 - / 3 *" answer_list = [] numerical_vals = "1234567890" valid_operators = "+ - * /" def calculate(expression): hold = [] reversed_hold = [] exp = "" expression_list = expression.spli...
import os, sys from sys import platform if platform == "linux" or platform == "linux2": if os.getuid() == 0: file_or_dir = input("File or Directory [file, dir]: ") file_name = input("File or directory name for search: ") find_dir = input("Finding directory: ") print() print("*********************...
################### Topics ####################### #What is variable ## DIfferent between mutable and immutale type Variable Type: Change in value in same memory (Mutable) and change in memory address when value changes (immutable). ## Stack and Heap memory : Queue and List . RAM and ROM #python is case sensitive # Pr...
#Decision making #Yield a Boolean True or False value # • The strings 'True' and 'False' both evaluate to Boolean True #Types of conditional expressions # Object identity, is # Arithmetic relational; e.g., > or == # Strings use the same equality and inequality operators as numeric objects # Several simple conditio...
#Iterators in Python: #Iterator in python is any python type that can be used with a ‘for in loop’. Python lists, tuples, dicts and sets are all examples of inbuilt iterators. These types are iterators because they implement following methods. In fact, any object that wants to be an iterator must implement following me...
n = int(input()) for i in range(n): arr = input().split() ans = [] for word in arr: ans.append(word[::-1]) print(*ans)
A = " " + input() B = " " + input() matrix = [[""]*(len(B)) for _ in range(len(A))] for i in range(1, len(A)): for j in range(1, len(B)): if A[i] == B[j]: matrix[i][j] = matrix[i-1][j-1] + A[i] else: if len(matrix[i - 1][j]) > len(matrix[i][j - 1]): matrix[i...
alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] ans = [-1 for i in range(26)] word = input() for i in range(len(word)): for j in range(26): if word[i] == alphabet[j] and ans[j] == -1: ans[j] = i break for i in ran...
""" lumberjack.py Simple tool that can be used to generate 2D BSP trees by hand. Currently limited to only vertical and horizontal partitions, because I'm bad at geometry. :( This tool uses the graphics.pyd extension module, which is an old wrapper around Pygame that I wrote a while back. graphics.pyd was intende...
from os import read buffer = None #readString reads a string to a buffer def readString(): global buffer buffer = read(0, 1000) #reads to the buffer if(buffer == 0): #Buffer has reached the end of the file return "EOF" return buffer def readLine(): global buffer ...
# Declare the variables input from the user : P = int(input("Enter the Principle Amount Please :")) n = int(input("Enter the Number of Years :")) r = float(input("Enter the rate of Interest :")) # Declare the formula A = P*(1+r/100)**n # The Final Amount print("The Total Amount including compound inter...
#You have been hired by the University of Data Science to manage their students' records. Your job is to create the student management system for the university. Let's try to build the system using basic Python operations. #After completing this project, you will get to know how to solve basic Python problems. In this...
from unittest import TestCase from blog.blog import Blog class BlogTest(TestCase): def test_create_blog(self): b = Blog('Test', 'Test Author') self.assertEqual('Test', b.title) self.assertEqual('Test Author', b.author) self.assertListEqual([], b.posts) # same assert as abo...
#!/usr/bin/env python import os import re import sys def convert_roman_to_arabic(roman): """Converts Roman numerals to Arabic number equilvalents @param num: Roman numeral to convert @type num: str @rtype: int @return: Integer equivalent of Roman numeral """ roman_numeral_patte...
# dictionary students = {'a':"ram", 'b': "govind", 'c': "asura"} student = ["ram","govind","asura"] print(students) print(students['a']) print(len (students)) for i,v in students.items (): print(i,v) for j in student: print(j)
import unittest from city import Neighborhood class NeighborhoodTest(unittest.TestCase): def testNeighborhood(self): sqMiles : float = 4.5 education : str = "Highschool" neighborhood : Neighborhood = Neighborhood(sqMiles, education) self.assertEqual(neighborhood.sqMiles, sqMiles) ...
#자료구조필요하니까 stack =[] def push(item): stack.append(item) def pop(): if len(stack) == 0: print("Stack is empty") #비어있는지 고려해야함! return else: return stack.pop() push(1) push(2) push(3) print(pop()) print(pop()) print(pop())
arr=[1,2,3] N=3 #sel안만들고, arr의 위치를 변경하면서 순열을 바꾸는것 def perm(idx): if idx==N: print(arr) return for i in range(idx,N): arr[idx],arr[i]=arr[i],arr[idx] perm(idx+1) arr[idx],arr[i]=arr[i],arr[idx] perm(0)
import sys sys.stdin = open("input.txt", "r") nums=[] for _ in range(9): nums.append(int(input())) MAX=max(nums) print(MAX,nums.index(MAX)+1,sep='\n')
import sys sys.stdin=open('input.txt') def reverse(s): global tmp for j in s[::-1]: tmp+=j reversed.append(tmp) if __name__=='__main__': n=int(input()) nums=list(input().split()) reversed=[] tmp='' for i in range(n): reverse(i)
import requests import json import csv # Define the URL of the API url = "https://api.steampowered.com/ISteamApps/GetAppList/v2/" # Define the query parameters params = { 'format':'json', } # Make a GET request to the URL with the parameters response = requests.get(url, params=params) if response.status_code == ...
def rendezett_e(lista) : """ Fuggveny ami eldonti, hogy a parameterkent kapott listaban novekvo sorrendben szerepelnek-e az elemek. Kis-nagybetukre mukodik ekezetesekre nem. """ if type(lista[0]) is str : for i in range(1,len(lista)) : #if lista[i - 1] >...
class Customer: def __init__(self): """constructor to instantiate customer object""" self.bikes = 0 self.rentalBasis = 0 self.rentalTime = 0 self.bill = 0 def requestBike(self): """Customer request bike to rent""" bikes = input("How many bikes would you like to rent?") try: bikes = int(bikes) ...
# First program number = range(101)#create a list of 100 values even_list = list()#create list for even values odd_list = list()#create list for odd values even = 0#number of even values odd = 0#number of odd values for i in number:#count the number of even and odd if i % 2 == 0: even += 1 else: ...
### This is part of Codecademy coding challenge ### Battleship with Python3 (single player version) import random ## function to create boards for player def create_board_computer(): board = { '1A':' ', '2A':' ', '3A':' ', '4A':' ', '5A':' ', '1B':' ', '2B':' ', '3B':' ', '4B':' ', '5B':' ', ...
def bubble_sort(nums): for i in range(len(nums)-1): for j in range(len(nums) -1 -i): if nums[j] > nums[j+1]: temp = nums[j] nums[j] = nums[j+1] nums[j+1] = temp return nums nums = [6,5,4,3,2,1] print(bubble_sort(nums)) nums = [-1, -2 ,-3, -4, -5, -6] print(bubble_sort(nums))
def merge_sort(nums): if len(nums) ==1: return 1 middle = int(len(nums)/2) left_half = nums[:middle] right_half = nums[middle:] merge_sort(left_half) merge_sort(right_half) i = 0 j = 0 k = 0 #merge the left and right subarrays based on values while i<len(left_half) and j<len(right_half): if left_half[...
class Counter(): def __init__(self, low, high): self.low = low self.current = low self.high = high def __iter__(self): return self def __next__(self): if self.current <= self.high: value = self.current self.current +=1 return valu...
class Person: def __init__(self): self.name = "Default" self.age = 0 self.skin_color = "Default" a = 100 b = 3 c = a + b print(c) p = Person() import pdb ; pdb.set_trace() print(p.name)
import unittest def is_anagram(s1, s2): if len(s1) != len(s2): return False if sorted(s1.replace(" ", "").lower()) != sorted(s2.replace(" ", "").lower()): return False return True def is_anagram2(s1, s2): if len(s1) != len(s2): return False storage = {} for i in rang...
from Card import Card import unittest class CardTests(unittest.TestCase): def test_create_card_with_correct_suite_and_value(self): """testing if card can be created""" c1 = Card("Hearts", "A") c2 = Card("Diamonds", "10") self.assertIsInstance(c1,Card) self.assertEqual(c1.s...
#tuples x=1,2,3 xx=(1,2,3) y=[1,2,3] z='hello' w=() a=(1,) b=(2) c=2, d=2 e=tuple(y) print(x,type(x),y,type(y),z,type(z),w,type(w),a,type(a),b,type(b),c, type(c),d,type(d),e,type(e)) # , is the tuple indicator print(e[0])
import math def get_prime(): print "Enter a prime number" p = int(raw_input()) for i in xrange(2, int(math.sqrt(p))): if p % i == 0: return 0 return p def calc_pub_key(root, priv, prime): return root ** priv % prime def calc_priv_key(pub, priv, prime): return pub ** priv % prime prime = 0 while(prime =...
def fibb(a): num = [] b=0 while b<a: if b==0 or b==1: num.append(1) else: num.append(num[b-2] + num[b-1]) b=b+1 return num print(fibb(15))
# -*- coding: utf-8 -*- """ Created on Wed Dec 5 16:54:10 2018 @author: thais """ #Transposição de matriz def transpor(A): #print(len(A)) B=[] for i in range(len(A)): B.append(A[i]) for i in range(len(A)): #print(i) k = A[i] for j in range(len(k)): ...
import pathlib def create_file(): """create a new file after first making sure the filename does not already exist in the current working directory """ proposed_filename = input("\nWhat filename would you like? ") while True: path = pathlib.Path(proposed_filename) # check for a ...
"""Scrape info about the five top-grossing movies for each year, for 10 years. Get the title and rank of the movie, the year, and how much money it grossed at the box office. Put the scraped data into a CSV file. """ from bs4 import BeautifulSoup import requests import csv def build_years_list(start): ...
# a simple example of a "black box" function # put in two words, and a string is returned # a and b are parameters # "love" and "Gators" are the arguments passed to the function # the value of result is returned def add_things(a, b): result = (a * 3) + (b * 3) return result # the data returned by the function...
"""A first simple test-run of the BeautifulSoup module, using a simple web page created just for this purpose. """ from urllib.request import urlopen from bs4 import BeautifulSoup # open a web page file page = urlopen("https://weimergeeks.com/examples/scraping/example1.html") # parse that to create a BeautifulSou...
# tested March 2023 # run Selenium without seeing the browser from selenium import webdriver # new headless stuff from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_argument("--headless=new") driver = webdriver.Chrome(options=chrome_options) from bs4 import BeautifulS...
print("What is your name?") name = input() print("How old are you?") age = input() if name == 'Alice' and int(age) < 13: print("How's Wonderland?") elif name == 'Alice': print("You are too old to enter through the looking glass, Alice.") elif int(age) < 13: print('This is only for Alice, kiddo.') else: ...
# -*- coding: utf-8 -*- import random from collections import defaultdict class GuessCityGameException(Exception): def __init__(self, msg): self.msg = msg class GuessCity(object): def __init__(self): self.__allowed_cities = defaultdict(list) self.__guessed_cities = set() self...
from typing import List, Tuple class SpellingHammingDictionary: def __init__(self): """ Initialize your data structure here. """ self.root = {} def add(self, word: str) -> None: node = self.root for l in word: if l not in node: node[...
# -*- coding: utf-8 -*- class SwedenNounLemmatizer: ARTICLE = { 'n': 'en', 't': 'ett' } def __init__(self): self.irregular_nouns = {} with open("resources/irregular_nouns.txt", "r") as f: for line in f: norm, plural = line.strip().split() ...
from typing import List class WordFilterTrie: def __init__(self, words: List[str]): self.suff = '#' self.word = '~' self.root = {} for word in words: self.insert(word) def insert(self, word: str) -> None: for i in range(len(word), -1, -1): ...
import operator import re import collections charfrequency = {} charfrequencysorted = {} alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] def decrypt(shift, path): finput = open (path, "r") inputstr = finput.read() outputstr = '' for ...
#Знайти всі чотирьохзначні числа, сума цифер яких дорівнює заданому числу #Задане число. перевірити чи дане число є простим number = int(input("Input number" + "\n")) if number <=0: print ("Incorrect number") elif number ==1: print ("1 is prime") else: for i in range(2,number): if number%i == 0: ...
#contol led with button press and count how many time button is pressed #importing gpio library import RPi.GPIO as gpio gpio.setmode(gpio.BOARD) #to use physical pin numbers on board gpio.setup(11, gpio.OUT) #set pin 11 as output gpio.setup(12, gpio.IN, pull_up_down = gpio.PUD_DOWN) #set pin 12 as input with pull ...
import random def sort_012(input_list): """ The idea is to put 0 and 2 in their correct positions, which will make sure all the 1s are automatically placed in their right positions """ # initialize pointers for next positions of 0 and 2 next_pos_0 = 0 next_pos_2 = len(input_list) - 1 ...
from priority_queue import PriorityQueue import sys class Node: def __init__(self, frequency=None, character=None): self.frequency = frequency self.character = character self.left_child: Node = None self.right_child: Node = None @property def has_left_child(self): ...
from union_and_intersection import intersection, union, LinkedList def make_linked_list(elements): linked_list = LinkedList() for i in elements: linked_list.append(i) return linked_list def helper(element_1, element_2, expected_union, expected_intersection): linked_list_1 = make_linked_list...
import time import random import sys item = [] def roomkey_1(): print_pause("You took the stairs for the sixth room.") print_pause("After a few moments, you find " "yourself in the staff survey room.") print_pause("you reached the sixth room ") if "key_1" in item: print_pause("...
#boj4233 가짜소수 def PrimeChk(num): for i in range(2,num+1): if i*i>num:break if num%i==0:return False return num!=1 def Fermat(num,Prime,mod): x=num;p=Prime result=1 while p: if p%2==1: result=result*x%mod x=x*x%mod p>>=1 return result while 1...
#boj11729 하노이 탑 이동 순서 def hanoi(n,beg,aux,end,l): if n==1: l.append([beg,end]) else: hanoi(n-1,beg,end,aux,l) hanoi(1,beg,aux,end,l) hanoi(n-1,aux,beg,end,l) n=int(input());l=[] hanoi(n,1,2,3,l) print(len(l)) for _ in l: print(*_)
#boj16649 Building a Stair def stair(cube): cnt=cube row=(cube+1)//2 print(row+1) pic='.'*(row+1)+'\n' for i in range(row): for j in range(row): if j==0 or i==row-1: pic+='o';cnt-=1 elif cube%2==0 and i==row-2 and j==1: pic+='o';cnt-=1;...
from GraphAPI import Graph from networkx.algorithms.shortest_paths import * import networkx as nx import time '''Bellman_Ford solution of shortest path''' class Bellman_Ford(object): def __init__(self, graph): #initialized graph input self.graph = graph def solver(self, source): dis...
from collections import defaultdict def max_equal_sum(E): D=defaultdict(int) # Map from abs difference to largest sum D[0]=0 # Start with a sum and difference of 0 print(D) for a in E: # Iterate over each element in the array D2=D.copy() ...
s = set(['aa','bb','cc']) l = ['bb','dd','aa','ee'] for name in l if name in set: s.remove(name) else: s.add(name) print s
def towers(n,frompeg,topeg,auxpeg): #if only 1 disk, make the move and return if n==1: print "\nMove disk 1 from peg %c to peg %c"%(frompeg,topeg) return # Move top n-1 disks from A to B, using C as auxiliary towers(n-1,frompeg,auxpeg,topeg) #Move remaining disks from A to C print "\nMove disk %...
from sys import argv #import of system statement script, input_file = argv # unpacking def print_all(f): #definition print f.read() # read the content of the file and print d same def rewind(f): # redefining seek function f.seek(0) # set the cursor position to the starting of the file def print_a_line(lin...
import datetime sundays=0 for year in range(1901,2001,1): for month in range(1,13,1): if datetime.date(year,month,1).weekday()==0: sundays+=1 print "number of sundays on which 1st of a month falls are",sundays
the_count = [1,2,3,4,5] fruits = ['apples', 'oranges','pears', 'apricots'] 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 "A fruit of type %s" %fruit #also we ca...
#!/usr/bin/env python #----------------------------------------------------------------------------- #joins IP Ranges to Locations and converts IP from an Int to Octets. import json import csv # converts Integer to binary (http://stackoverflow.com/questions/699866/python-int-to-binary) # ex: toBinary(3640355304) = '...
from functools import *; def Acceptdata(): size=int(input("enter the no of elements")); arr=list(); print("enter the element in list"); for i in range(0,size,1): print("enter element ",i+1); a=int(input()) arr.append(a) return arr; def Evenno(no1): return (no1%2=...
def Countdigit(ino): icnt=0 while (ino>0): ino = ino // 10 icnt=icnt+1 return icnt print("enter the no") a=int(input()) iret=Countdigit(a) print("the no of digit is",iret)
class Circle: PI=3.14; def __init__(self): self.Radius=0.0; self.Area=0.0; self.Circumference=0.0; def Accept(self): self.Radius=int(input("enter the radius")); def CalculateArea(self): self.Area = Circle.PI*...
def Prime(ino): isum=0; if ino<0: ino=-ino; for i in range(1,ino): if ino%i==0: isum=isum+i; if isum==1: return True else: return False print("enter the number") a=int(input()) bret=Prime(a) if bret==1: print("it ...
def Pattern1(ino): for i in range(0,ino): print("\n"); for j in range(0,ino): print("*",end =' '); #print("\n"); print("enter the number") n=int(input()) Pattern1(n)
from functools import *; def Acceptlist(): size=int(input("enter the no of element")) ab=list(); print("enter the number in list "); for i in range(0,size,1): print("enter number", i+1); n=int(input()) ab.append(n) return ab; def grtles(no): if ((no>=7...
def Minno(ele): min=ele[0]; for i in ele: if i<min: min=i return min; def main(): size=int(input("enter the no of elements ")) a= list(); print("Insert the Element in list"); for i in range(0,size,1): print("Enter element ",i+1) no=int(input())...
""" This function, combinations(iterable, r), takes an iterable and an integer and returns subsequences of elements with a length of r. These subsequences of elements are in the form of tuples. One thing to note that the order of the elements in these tuples will reflect their original order in the initial iterable. S...
#this program will inform users if they can or cannot enter the casino #ask user for their age age = int(input("How old are you? ")) #tell user if they are allowed in the casino or not if age >= 21: print("Welcome to Cassie's Casino") else: print("Sorry you cannot enter") #quit program input("press any key t...
#the purpose of this program is to convert a dogs age to human years #if the user enters a non-numeric value, the error will be handled with a Try Except #ask user to enter dogs age and convert age to an integer try: dog_age = int(input("Enter your dogs age: ")) human_age = dog_age * 7 print(f"Your ...
#challenge 1 #create a loop that prints the numbers 1 through 100 i = 0 while i < 101: print(i) i = i+1
#creating a dictionary to store information about our yoga classes yoga = {'Instructor' : 'Jane', 'Location': 'Plum Center', 'Price': 199, 'Students' : ['Alex', 'Carl', 'Connie'] } #print dictionary print(yoga) #Iterating over dictionaries like iterating over lists ...
#asks user to enter a number and print if the number is odd or even x = int(input("Enter a number: ")) if x<0: print("That is negative number") elif x ==0: print("This number is neither postive or negative") else: print("That is a positive number") input('Press any key to quit')
#comparison operators check age = 18 #each of these operators return a True or False value #True or False are known as Boolean values #Is age greater than 30? age > 30 #Is age less than 30? age < 30 #Is greater than or equal 30? age >=30 #Is age less than or equal 30 age <=30 #Is age exactly 3...
class Room: def __init__(self, room_id): self.room_id = room_id self.title = None self.description = None self.elevation = None self.terrain = None self.available_directions = [] self.traveled_directions = [] self.n_to = None self.s_to = None ...
#More prints with escape characters to practice print "Let's practice everything." print 'You\'d need to know \'bout escapes with \\ that do \n newlines and \t tabs.' #Printing string : A poem to print later. Just a variable holding set of lines poem=""" \tThe lovely world with logic so firmly planted cannot discern ...
from sys import argv #Take input file script, input_file = argv #function to print input file contents def print_all(f): print f.read() #function to rewind the file def rewind(f): f.seek(0) #function to print a line def print_a_line(line_count, f): print line_count, f.readline() #Open the input file current_fil...
str1 = input("Enter the first string: ") str2 = input("Enter the second string: ") len1 = len(str1) len2 = len(str2) count = 0 max_count = 0 i = i1 = i2 = 0 subseq = [] while i < len1: i1 = i i2 = 0 while i1 < len1 and i2 < len2: if str1[i1] == str2[i2]: count += 1 i1 += 1 ...
import functools class Employee: def __init__(self,id,name,des,sal): self.id=id self.name=name self.des=des self.sal=sal def printemp(self): print("name=",self.name) print("designation=",self.des) print("sal",self.sal) def __str__(self): #retu...
num1=int(input("enter num")) num2=int(input("enter num")) if(num1>num2): print("num1 max") elif(num1<num2): print("num2 max") else: print("equal")
list=[10,11,12,13,14,15,2,3,4] list.sort() print(list) low=0 upp=len(list)-1 ele=int(input("enter ele")) flag=0 while(low<=upp): mid=(low+upp)//2 if(ele>list[mid]): low=mid+1 elif(ele<list[mid]): upp=mid-1 elif(ele==list[mid]): flag=1 bre...
num1=int(input("enter num")) num2=int(input("enter num2")) num3=int(input("enter num3")) if((num1>=num2)&(num1>=num3)): t=num1 if((num2>=num3)): tt=num2 ttt=num3 print(ttt,tt,t) else: f=num3 ff=num2 print(ff,f,t) elif((num2>=num1)&(num2>=num3)): s=num2 ...
n = int(input("Enter the number: ")) a=0 b=1 print(a, b,end=' ') for i in range(2,n): c=a+b print(c,end=' ') a=b b=c
class Employee: def __init__(self, id, name, desig, salary): self.id = id self.name = name self.designation = desig self.salary = salary def printValues(self): print(self.id) print(self.name) print(self.designation) print(self.salary) def __st...
lst=[1,2,3,4] ele=int(input("enter ur ele")) for i in lst: for j in lst: if(i+j==ele): print(i,j) else: pass
# -*- coding: utf-8 -*- """ logger.py Manages logging. :copyright: (c) 2016 by Robert Johansson. :license: BSD, see LICENSE for more details. This module can be used to do basic logging and be used instead of print method. Logging can be done to stdout, a file or a custom logger. Example...
#Jessica De Mota Munoz #jessica.demotamunoz86@myhunter.cuny.edu #September,11,2019 #we need to use a variable to assign our user input #our user needs to be able to insert any message; think of it like a chatbox #so in this case we use the variable greeting to make a user input to insert a message greeting = input("Pu...