Python Tutorial 7
Python Tutorial 7
Expected output:
cia
Mi6
Isi
Syntax:
words=input("Enter list of words:")
splitted= words.split(",")
for x in splitted:
if "secret" not in x:
print(x)
OUTPUT:
Implement a program that requests a list of student names from the user and prints
those names that starts with letters A through M.
Expected output:
Ellie
Gavin
Syntax:
words=input("Enter list:")
split= words.split(",")
for word in split:
if word[0] in 'ABCDEFGHIJLM':
print(word)
OUTPUT:
Implement a program that requests a non empty list from the user and prints on the
screen a message giving the first and last element of the list.
Expected output:
Syntax:
OUTPUT:
Implement a program that requests a positive integer n from the user and prints the
first four multiples of n:
Expected output:
Enter n: 5
10
15
Syntax:
n=input("Enter n:")
for x in range(4):
multiples=int(n) * x
print(multiples)
OUTPUT:
Implement a program that requests an integer n from the user and prints on the
screen the squares of all numbers from 0 up to, but not including n.
Expected Output:
Enter n: 4
Syntax:
n=input("Enter n:")
for x in range(int(n)):
square=x**2
print(square)
OUTPUT:
Implement a program that requests a positive integer n and prints on the screen all
the positive divisors of n. Note: 0 is not a divisor of any integer and n divides itself.
Expected Output:
Enter n: 49
49
Syntax:
n=int(input("Enter n:"))
for x in range(1,n+1):
if(n%x==0):
print(x)
OUTPUT:
Implement a program that requests four numbers (integer or floating-point) from
the user. Your program should compile the average of the first three numbers and
compare the average to the fourth number. If they are equal, your program should
print ‘Equal’ on the screen.
Expected Output:
Equal
Syntax:
a= float(input("Enter first number:"))
b= float(input("Enter second number:"))
c= float(input("Enter third number:"))
d= float(input("Enter last number:"))
e =(a + b + c)/3
if e==d:
print("Equal")
OUTPUT: