Python Free Certificate Completion Course.
Join Now
Apply Coupon Code : 676D1C6707AF450A4C8D
Note:-Coupon Code Valid Only Today
Assignment Questions&Answer:-
1.Assign your name in a variable and then print it in below cases:
Uppercase
Lowercase
Titlecase
name="AeRaAf"
print(name.upper()) #Uppercase
print(name.lower()) #Lowercase
print(name.title()) #Titlecase
2.Assign name 'John' in a variable and print the message 'John, how are you?' using the variable in print()
name="John"
print(name+", how are you?")
3.Print message ' When you do not create things, you become defined by your tastes rather than ability ' using a variable
message=' When you do not create things, you become defined by your tastes rather than ability '
message=message.strip()
print(message)
4.Print message 'Your age is 25'
age=25
print("Your age is "+str(age))
5.Print the text as below using one print function
NAMES:
Tom
Tim
Jack.
print("NAMES:\n\tTom\n\tTim\n\tJack")
6.Store text "Hello World! This is my first Python program." in variable 'message' and then print the message.
message="Hello World! This is my first Python program."
print (message)
7.Create a List with names of your loved ones. Add 3 Names.
E.g. abc, def, ghi
List_Family=['Mother','Father','Brother']
8.Print a message greeting your loved ones, message should be the same
"[Name here], good morning"
print(List_Family[0]+", good morning")
print(List_Family[1]+", good morning")
print(List_Family[2]+", good morning")
9.Replace the name of one person from the list adding a new name in the list. E.g. 'def' with 'jkl'
List_Family[2]='Sister'
print(List_Family)
10.Store the names of the 5 places you have visited in a list and print it.
places=['US', 'France','Spanish','UK','India']
print(places)
11.Sort the list alphabetically and then print it.
print(sorted(places))
12.Reverse the items of the list.
places.sort(reverse=True)
13.Sort the list permanently and print it.
print(places.sort())
14.Find the length of the list.
len(places)
15.Store the name of 5 places you want to visit and print the name of places using for loop.
places=['US', 'France','Spanish','UK','India']
for a in places:
print(a)
16.Now add a message "I like [name of place]" using for loop
places=['US', 'France','Spanish','UK','India']
for a in places:
print("I like "+a)
17.Using for loop create and print a list of numbers from 1 to 10.
for a in range(1,11):
print(a)
18.Create a list 1 to 10 numbers and print minimum and maximum.
num=[1,2,3,4,5,6,7,8,9,10]
min(num)
max(num)
19.Create a list of 1 to 10 numbers and print list of odd numbers.
num=[1,2,3,4,5,6,7,8,9,10]
for a in range(1,11,2):
print(a)
20.Append exponents of numbers from 1 to 10 into an empty list
num=[]
for a in range(1,10):
value=a**2
num.append(value)
print(num)
21.Create a list of 1 to 10 numbers and print list of even numbers
num=[1,2,3,4,5,6,7,8,9,10]
for a in range(2,11,2):
print(a)
22.Using the list cars=['bmw','audi','toyota','hyundai','ferrari'], print the first 3 elements using slicing in for loop.
cars=['bmw','audi','toyota','hyundai','ferrari']
for a in cars[0:3]:
print(a)
23.Using the list cars=['bmw','audi','toyota','hyundai','ferrari'], print the last 3 elements using slicing in for loop.
cars=['bmw','audi','toyota','hyundai','ferrari']
for a in cars[-3:]:
print(a)
24.Using the list cars=['bmw','audi','toyota','hyundai','ferrari'], print 'audi' and 'toyota' using slicing in for loop.
cars=['bmw','audi','toyota','hyundai','ferrari']
for a in cars[1:3]:
print(a)
25.Copy list cars=['bmw','audi','toyota','hyundai','ferrari'] into new_cars list and print it
cars=['bmw','audi','toyota','hyundai','ferrari']
new_cars=cars[:]
print(new_cars)
26.Define a tuple that holds the dimensions of triangle and print out the values one at a time.
triangle=(100,200,300)
print(triangle[0])
print(triangle[1])
print(triangle[2])
27.Print the dimensions of triangle using for loop.
triangle=(100,200,300)
for a in triangle:
print(a)
28.Redefine the tuple that holds the dimensions. Add 50 to all 3 sides and print the dimensions using for loop.
triangle=(100,200,300)
triangle[0]=150
triangle[1]=250
triangle[2]=350
for a in triangle:
print(a)
29.Write an if statement that checks if a is more than 10 and prints message "a is greater than 10" if true.
Consider a=11.
if a>10:
print("a is greater than 10.")
30.Write an if statement that checks if a is more than 10 and prints message "a is greater than 10" if true else prints message "a is less than 10".
Consider a=11.
if a>10:
print("a is greater than 10.")
else:
print("a is less than 10.")
31.Write a program that prints messages accordingly:
-age less than 18, print message "Your ticket fare is $5"
-age equal or more than 18 but less than 50, print message "Your ticket fare is $10"
-age equal or more than 50, print message "Your ticket fare is $7.5"
age=50
if age<18:
print("Your ticket fare is $5")
elif age>=18 and age<49:
print("Your ticket fare is $10")
else:
print("Your ticket fare is $7.5")
32.Consider below list, print a message 'Car Audi is available' if it is present in the list:
cars=['audi','bmw','toyota','ferrari','Hyundai']
if 'audi' in cars:
print("Car Audi is available")
33.Create a Dictionary for one person with below parameters as keys and enter the values you like accordingly. Once done print each value one at a time.
-First_Name
-Last_Name
-Age
User1={
'First_Name':'Aeraaf',
'Last_Name':'Patel',
'Age':29,
}
34.Modify the value of 'First_Name' key created in question 1 and print it out.
User1['First_Name']='John'
print(User1['First_Name'])
35.Using for loop print out all the keys used in Dictionary created in question 1.
for a in User1.keys():
print(a)
36.Using for loop print out all the values used in Dictionary created in question 1.
for a in User1.values():
print(a)
37.Make 2 dictionaries, each dictionary has below keys:
first_name, last_name
Store this 2 dictionaries inside a list named 'person'.
person1={'first_name':'Aeraaf'}
person2={'last_name':'Patel'}
person=[person1,person2]
38.Loop through the list 'person' and print everything(i.e. first_name and last_name) for each person.
person=[person1,person2]
39.Make dictionary called Cities. Use names of Cities as keys of dictionary. Create a dictionary of information about each city which include the country that city is in, one fact. The keys for each city should be country, fact. Print the name of each city and all of the information you have stored about it.
person=[person1,person2]
ReplyDeleteFree udemy Course
Free udemy Course
Free udemy Course
Free udemy Course
Free udemy Course
Free udemy Course
Free udemy Course
Free udemy Course
Valuable post useful for everyone. Keep on sharing.
ReplyDeletePython Online Training
Three are usually cheap Ralph Lauren available for sale each and every time you wish to buy. corso lis
ReplyDelete