It is practice time to improve logical skills and our knowledge of coding
Practice programs:
1. Make a program that solves and shows the summation of 64 + 32.
solution:
>>> x = 10
y = 20
# using third variable
z = x + yprogram
print( z )
output:
30
2. Do the same as in 2, but make it sum x + y.
>>> x = 10
y = 20
print( x + y )
output:
30
3. How many glasses of water you drink every day?
Hint: take a variable and assign a number of glasses of water and print
>>> # using snake case type for variable name
number_of_glasses_of_water = 8
print( ' I drink ', number_of_glasses_of_water, ' glasses of water everyday ' )
output:
I drink 8 glasses of water every day
4. Create a variable named car name and assign the value of your car name to it.
>>> car_name = ' BMW '
print( ' My favourite car is ', car_name )
5.There are two friends in a school who started talking to each other about their hobbies? Write a program to print their conversation and take two variables to store their names. While printing display their names in each conversation to differentiate their roles.
>>> friend_1 = ' Jessy '
friend_2 = 'Vaishu '
print( friend_1+':', ' hi vaishu how r u ')
print( friend_2+':','hi i am good, thanks' )
print( friend_1+':','what are your hobbies' )
print( friend_2+ ' : ' ,'i like dance, yours?' )
print( friend_1+':',' nice! i like music' )
print( friend_2+':',' ok bye see you soon!' )
print( friend_1+':','ok bye take care' )
output:
friend_1: hi vaishu how r u
friend_2:hi i am good, thanks
friend_1:what are your hobbies
friend_2: i like dance, yours?
friend_1: nice! i like music
friend_2: ok bye see you soon!
friend_1:ok bye take care
Project1:
Imagine you’re working in a transportation company, and your boss asked you to prepare a status report. This should include the total number of buses, space in each bus, number of drivers, the number of passengers, buses that are not used, buses used, the total bus capacity, and the average passengers per bus.
buses = 100space_in_a_bus = 20.0drivers = 30passengers = 130buses_not_driven = to be calculatedbuses_driven = to be calculatedtotal_capacity = to be calculatedaverage_passengers_per_bus = to be calculated
1. Declare and initiate all the variables for this project # Use the given variable names and values to do so, if the variable has no value, then you need to do some math to calculate it's vale, E.G. average_passengers_per_bus = passengers / buses_driven
2. Print the obtained values in useful sentences, E.G. print "There are", buses, "buses available."
Solution:
buses = 100
space_in_a_bus = 20
drivers = 30
passengers = 130
buses_not_driven = buses-drivers
buses_driven = space_in_a_bus*drivers total_capacity=passengers/drivers average_passengers_per_bus= passengers/driversprint(' there are ',buses,'buses available')
print(' there are only',drivers,'drivers available ')
print(' there will be',buses_not_driven,'empty buses today ')
print(' we can transport,buses_driven,'people today ')
print(' we have',passengers,' passengers today ')
print(' we need to put about,total_capacity,'passengers in each bus ')
output:
there are 100 buses available
there are only 30 drivers available
there will be 70 empty buses today
we can transport 600.0 people today
we have 130 passengers today
we need to put about 4.33333333333 passengers in each bus
Project 2:
The purpose of this project is to let Python talks about your friend, using his/her information, such as age, height, weight, hair color, eyes color and create a small descriptive paragraph about your friend.
Your_friend_name = 'name here'
= age here
Your_friend_height = height here
Your_friend_weight = weight here
Your_friend_eyes = 'eyes color here'
Your_friend_teeth = 'teeth color here'
Your_friend_hair = 'hair color here'
After inserting your friend’s information into the code below, you need to let Python build a small descriptive paragraph about your friend. The output should be:
Let's talk about (your friend's name'
He's 'your friend height' inches tall.
He's 'your friend weight' pounds heavy.
Actually, that's not too heavy.
He's got 'your friend eyes color' eyes and 'your friend hair color' hair.
His teeth are usually 'your friend's teeth color' depending on the coffee.
If I add 'age', height, and 'weight' I get 'addition result'.
solution:
Your_friend_name = 'Felix'
Your_friend_age = 19
Your_friend_height = 160
Your_friend_weight = 80
Your_friend_eyes = 'blue'
Your_friend_teeth = 'white'
Your_friend_hair = 'black'
addition=Your_friend_age+Your_friend_height+Your_friend_weight
print (' lets talk about', Your_friend_name)
print (' He is', Your_friend_height,'tall' )
print (' He is ',Your_friend_weight,'pounds heavy' )
print (' Actually, thats not too heavy' )
print (' He is got', Your_friend_eyes,'eyes and', Your_friend_hair,'hair' )
print (' His teeths are usually',Your_friend_teeth,'depending on the coffee' )
print('If I add age,height, a weight',Your_friend_age,Your_friend_height,Your_friend_weight,' I get',addition)
OUTPUT:
lets talk about Felix
He is 160 tall
He is 80 poundas heavy
Actually, thats not too heavy
He is got blue eyes and black hair
His teeth are usually white depending upon the coffee
If I add age, height, a weight I get 259
😇HAPPY CODING BUDDIES😊
PRACTICE MORE👍
Visit all posts to learn more🙋


No comments:
Post a Comment