def askForInput(prompt=None): try: threading except NameError: import threading try: console except NameError: import console if (threading.currentThread() in console.ignoredThreads): return "" else: return console.input(prompt)
variable_expense = int(id_input_data['Variable Expense']) fixed_saving = int(id_input_data['Fixed Savings']) is_life_insurance = int(id_input_data['is_life_insurance']) is_medical_insurance = int(id_input_data['is_medical_insurance']) # print message print('In our database, your:') print('') print(f'Fixed income is {fixed_income}') print(f'Fixed expenses is {fixed_expense}') print(f'Fixed saving is {fixed_saving}') print(f'Estimated variable expenses is {variable_expense}') print(f'is_life_insurance is {is_life_insurance}') print(f'is_medical_insurance is {is_medical_insurance}') print('') update = input("Do you wish to update anything? \nAnswer: ", ) print('') if update == 'yes': fixed_income, fixed_expense, variable_expense, fixed_saving, is_life_insurance, is_medical_insurance = fixed_input( user_id) # variable values month, year, variable_income, variable_saving, account_balance = variable_input( ) # save new input new_input = [ user_id, month, year, fixed_income, variable_income, fixed_expense, variable_expense, fixed_saving, variable_saving, account_balance, is_life_insurance, is_medical_insurance
1.Write a program to take string "Welcome to ksit" and count the number of spaces in the String. s=input('enter a string\n') ans=s.count(" ") print(ans) 2.Write a program which can compute the factorial of a given number using function(recursion).The output should be a comma seperated value in the console. def factorial(n): if n == 1: return n else: return n*factorial(n-1) num = int(input("Enter a number:")) if num < 0: print("Enter positive number only") elif num == 0: print("The factorial of 0 is 1") else: print("The factorial of",num,"is",factorial(num)) 3.With a given integer number n write a program to generate an output in the following pattern.If n=3 the output should be of the form 1:1 2:4 3:9 n=int(input("Enter the number")) i=1 while i<=n: print(i,":",i**2) i=i+1
Then, the output should be: 40320 Hints: In case of input data being supplied to the question, it should be assumed to be a console input. Solution: def fact(x): if x == 0: return 1 return x * fact(x - 1) x=int(raw_input()) print fact(x) #----------------------------------------# print(list(range(int(input()),0,-1))) #----------------------------------------# Question 3 Level 1 Question: With a given integral number n, write a program to generate a dictionary that contains (i, i*i) such that is an integral number between 1 and n (both included). and then the program should print the dictionary. Suppose the following input is supplied to the program: 8 Then, the output should be: {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64} Hints: In case of input data being supplied to the question, it should be assumed to be a console input. Consider use dict()
def get_String(self): self.str1 = input("Enter a string:")
def askForInput(prompt=None): if (threading.currentThread() in Pyto.ignoredThreads): return "" else: return Pyto.input(prompt)
and:1 between:1 choosing:1 or:2 to:1 #----------------------------------------# #Question 23 Write a method which can calculate square value of number #----------------------------------------# #Question 24 write a program to print some Python built-in functions documents, such as abs(), int(), input(). And add document for your own function. #Hints: The built-in document method is __doc__ #----------------------------------------# #Question 25 Define a class, which have a class parameter and have the same instance parameter. #Hint: Define a instance parameter, need add it in __init__ method You can init a object with construct parameter or set the value later #----------------------------------------# #Question 26