Zipfile with Problems: extract-methods.zip
Zipfile with Problems and Answers: extract-methods-ans.zip
inches = float(input("Enter length in inches: ")) cm = inches * 2.54 print("Length in cm is:", cm)
feet = float(input("Enter length in feet: ")) inches = float(input("Enter additional inches: ")) cm = (feet * 12 + inches) * 2.54 meters = cm / 100 print("Length in meters is:", meters)
word = input("Input word: ") if len(word) > 0: first = word[0] else: first = "" print("First character:", first)
n = int(input("Input a positive int: ")) factors = [1] for f in range(2, n): if n % f == 0: factors.append(f) factors.append(n) print("Factors of n:", factors)
file_name = input("Input file name:") fin = open(file_name, "r") values = [ ] for line in fin: value = int(line) values.append(value) print("List of values: ", values)
file_name = input("Input file name: ") fin = open(file_name, "r") values = [ ] for line in fin: row = [ ] items = line.split(" ") for item in items: value = int(item.strip( )) row.append(value) values.append(row) fin.close( ) print("List of values: ", values)