Friday, July 16, 2021

# 5. a. Solutions for input function questions

 Practice Programs


Its practice time!!  

1. Create a login form.

     Print(‘Login form’)

  Username=input(‘User Name:’)

  Password=input(‘Password:’) 

  Output: 

  Login form 

  User Name: javed 

  Password:  *****

   2. Using input() function ask for user's name.

Name=input(‘Enter your name:’)

Output:

Enter your name: javed  

 3.  Ask user a numerical question, such as, "Please enter your age."

Age=int(input(‘Please enter your age:’))

Output:

Please enter your age: 22

    4. Using input() function, print() function and ask for the current year, then              print          the answer

Year=int(input(‘Enter current year:’)

Print(‘Current year is’)

Output:

Enter current year: 2021

Current year is 2021

5. Accept two numbers from the user and perform multiplication,addition, subtraction, division, modulus, floor division, power 

number1=int(input('enter first number:')

number2=int(input('enter second number:')

print(number1*number2,'multiplication')

print(number1+number2,'addition')

print(number1-number2,'subtraction')

print(number1/number2,'division')

print(number1%number2,'modulus')

print(number1//number2,'floor division')

print(number1**number2,'power') 

Output:

enter first number:5

enter second number: 2

multiplication:10.0

addition: 7.0

subtraction: 3.0

division: 2.5

modulus:1

floor division: 2

power: 25

 

 

project:

In a college, an awareness webinar was conducted on covid-19 topic. That was conducted by the health department. After the program the department want to know how was the program as feedback from the students. The department decided to take feedback digitally. Can you help the department by writing program on feedback form so that they can easily get their feedback.

first_name= input('first name:')

last_name=input('second name:')

emailid=input('emailid:')

print('What percentage of the information was new to you?')

q1=input('Select: 100% 75% 50% 25% 0%')

print('I can use this session information:')

q2=input('Select: Immediately In 2-6 months In 7-12 months Never')

print('Would you like to learn more about this topic?')

q3=input('Select: Yes No')

print('Please rate the speaker’s knowledge of the topic:')

q4=input('Select: Excellent Good Fair Poor')

print('Please rate the speaker’s presentation skills:')

q5=input('Select: Excellent Good Fair Poor')

print('Please rate the content of the slides/virtual aids:')

q6=input('Select: Excellent Good Fair Poor')

print('How accurate was the session description?')

q7=input('Select: Excellent Good Fair Poor')

print('How did the session compare to your expectations?')

q8=input('Select: Excellent Good Fair Poor')

print('Overall session evaluation:')

q9=input('Select: Excellent Good Fair Poor')

print('How likely are you to recommend this session to a colleague? (with 10 being most likely to recommend)')

q10=input('Select: 0 1 2 3 4 5 6 7 8 9 10')

print('Please rate your overall experience:')

q11=input('Select: Excellent Good Fair Poor')

Output:

first name: javed 

second name: mohammed

emailid: javedmohammed@gmail.com

What percentage of the information was new to you?

Select: 100% 75% 50% 25% 0%  : 50

I can use this session information:

Select: Immediately In 2-6 months In 7-12 months Never : 5

Would you like to learn more about this topic?

Select: Yes No : yes

Please rate the speaker’s knowledge of the topic:

Select: Excellent Good Fair Poor : excellent

Please rate the speaker’s presentation skills:

Select: Excellent Good Fair Poor : excellent

Please rate the content of the slides/virtual aids:

Select: Excellent Good Fair Poor : excellent

How accurate was the session description?

Select: Excellent Good Fair Poor : good

How did the session compare to your expectations?

Select: Excellent Good Fair Poor : good

Overall session evaluation:

Select: Excellent Good Fair Poor : fair

How likely are you to recommend this session to a colleague? (with 10 being most likely to recommend)

Select: 0 1 2 3 4 5 6 7 8 9 10 : 9

Please rate your overall experience:

Select: Excellent Good Fair Poor : excellence


HAPPY LEARNING👍

PLEASE READ AND FOLLOW US💜

😇THANKS FOR SUPPORTING😇 


# 5. Python Input function

                                             Input ( ) function in python

Now let us make computer to take input from us.

Lets start our journey with python!


Python has an input function which lets you ask a user for some text input. You call this function to tell the program to stop and wait for the user to key in the data.

Taking user input by using input() function.

>>> input ( ) 

I am learning python

Output : ‘ I am learning python ‘

Now lets make it more meaningful to take input from the user. Add some meaningful text inside function using either single ' ' or double quotes " ".

input() function by default will take everything as string.

>>> input ( “ Enter your name: ” )

Enter your name: Satish

Output : ‘ Satish ‘

>>> name = input ( “ enter your name : “)

        age = input ( “ enter your age : “ )

        print ( name, age )

enter your name : Satish

enter your age : 35

Output :  Satish    35

In the above program both name and age are in string format.

>>>  name = input ( “ enter your name : “)

        age = input ( “ enter your age : “ )

        print ( name, age )

enter your name : Satish

enter your age : python

Output : Satish        python

“ “ “ In the above program whenever we enter age as string it is accepting because input() function is by default string. But age should not be a string it should be a number, to get this we should convert string to integer.” “ “

int values:

>>>name = input ( “ enter your name : “)

        age =int ( input ( “ enter your age : “ ) )

        print ( name, age )

enter your name : Satish

enter your age : 35

Output :  Satish    35

#  In the above program if we try to enter string in age we will get error

float values:

>>> name = input ( “ enter your name : “)

        age =int( input ( “ enter your age : “ ) )

        weight = float (input (“ enter your weight: ” ) )

        print ( name, age, weight )

enter your name : Satish

enter your age : 35

enter your weight : 55.5

Output :  Satish    35      55.5

Practice Programs:

1.    Create a login form.

2.    Using input() function ask for user's name.

3.    Ask user a numerical question, such as, "Please enter your age."

4.    Using input() function, print() function and ask for the current year, then print the answer  

5. Accept two numbers from the user and perform multiplication,addition, subtraction, division, modulus, floor division, power 

 

    project: 

     In a college, an awareness webinar was conducted on covid-19 topic. That was conducted by the health department. After the program the department want to know how was the program as feedback from the students. But its not hygienic to take feedback manually, so the department decided to take feedback digitally. Can you help the department by writing program on feedback form so that they can easily get their feedback.


Refer next post for answers

Thanks for visiting

 

 

 

 

Friday, June 25, 2021

# 3. a. variable practice questions solutions

 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 = 100
space_in_a_bus = 20.0
drivers = 30
passengers = 130
buses_not_driven = to be calculated
buses_driven = to be calculated
total_capacity = to be calculated
average_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/drivers

print(' 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🙋

# 7. Type conversion in Python

                                      Type Conversion in Python Python defines type conversion functions to directly convert one data type t...