Lecture 2.2: Python Basic Input Output and Comments ।। Python for Research

preview_player
Показать описание
Online Free Course: Python for Research.

গবেষক হতে চাই:: Be Researcher BD (BRBD) arranged the most demanding online free course titled "Python for Research". Python is widely used in research areas including Data Science, Computer Vision, Natural Language Processing, Signal Processing, IoT, Agriculture, Business Studies, Economics, Sociology, etc. All the technical and nontechnical sectors are now using python for their research purposes (Data Preprocessing, Analysis, Visualization, etc).

This lecture covered the following topics:
1:26 - Points to be discussed
1:53 - Basic of Input
5:25 - User-friendly message
7:10 - Multiple input using one input() function
9:33 - Basic of Output
10:11 - Different output format
13:48 - Multiple outputs in one line
15:29 - Use of format specifier
17:51 - Comments
21:26 - Practical Session

Our newly designed "Python for Research" focuses on the research tools using python. From this course, we can get a primary knowledge of how python is using in research. This course covers from the beginning of the basic python, conditional statements, loops, functions, data structures, and some python libraries like Numpy, Scipy, Matplotlib, Pandas, Seaborn, SKLearn, etc. And at the ending, we will conduct a real-life project using our tools of this course.

About the Mentor and Instructor:

Keep your eyes on our page and group for updates. Join with us:

References:

#pythonforresearch #BRBD_Training #BRBD_Course
#MdSabirHossain #MahmudulHasanMoon
#Gobeshokhotechai #BeResearcherBd #গবেষকহতেচাই
Рекомендации по теме
Комментарии
Автор

Answers to the Assignment number 2:

1. Take three numbers as input and find the sum of them.


In [13]:
a=int(input("What is the value of a=?"))
b=int(input("What is the value of b=?"))
c=int(input("What is the value of c=?"))
sum=a+b+c
print("The sum of", a, "and", b, "and", c, "is", sum)

What is the value of a=?2
What is the value of b=?5
What is the value of c=?7
The sum of 2 and 5 and 7 is 14

2. Take the radious of a circle as input and find the area of the circle. Answer should be 3 decimal point


In [22]:
r=float(input("Enter the radius of the Circle?"))
A=3.1416*(r*r)
print("Area of the Circle is %.3f"%A)


Enter the radius of the Circle?5
Area of the Circle is 78.540

3. Take two number as input by one input function and calculate their additiob, subtraction, multiplication and division.


In [31]:
a, b=map(int, input("Enter two numbers here! Press'SPACE'after finsihing each number").split())
add=a+b
subs=a-b
multi=a*b
divi=a/b
print("Addition is", add)
print("Subtraction is", subs)
print("Multiplication is", multi)
print("Division is", divi)


Enter two numbers here! Press'SPACE'after finsihing each number10 5
Addition is 15
Subtraction is 5
Multiplication is 50
Division is 2.0

4. Input 3 float numbers and find their average and print like this. "the average of a, b and c is d", use any output formating


In [33]:
a, b, c=map(float, input("Enter three Float numbers here! Press'SPACE'after finsihing each number").split())
avg=(a+b+c)/3
print("The average of %.2f, %.2f and %.2f is %.2F"%(a, b, c, avg))


Enter three Float numbers here! Press'SPACE'after finsihing each number10.1 20.2 30.3
The average of 10.10, 20.20 and 30.30 is 20.20

5. Take 3 integer and 3 float number and find the difference between the integers and floats.

In [35]:
a, b, c=map(int, input("Enter three integer numbers here! Press'SPACE'after finsihing each number").split())
d, e, f=map(float, input("Enter three Float numbers here! Press'SPACE'after finsihing each number").split())
integers=a+b+c
floats=d+e+f
difference=integers-floats
print("The differnce is", difference)


Enter three integer numbers here! Press'SPACE'after finsihing each number10 20 30
Enter three Float numbers here! Press'SPACE'after finsihing each number5.5 6.5 7.7
The differnce is 40.3

6. Input three string by one input function and make a sentence using the three string.


In [36]:
a, b, c=map(str, input("Enter three Strings here! Press'SPACE'after finsihing each number").split())
print(a, b, c)


Enter three Strings here! Press'SPACE'after finsihing each numberHow are you?
How are you?

7. input 2 number as string, convert them to number, find their sum then convert the sum to string and print using format specifier.


In [38]:
a, b=input("Enter two integer numbers here! Press'SPACE'after finsihing each number").split()
c=int(a)
d=int(b)
sum=c+d
n_sum=str(sum)
print("The sum of %s and %s is %s"%(a, b, n_sum))


Enter two integer numbers here! Press'SPACE'after finsihing each number10 20
The sum of 10 and 20 is 30

8. Print the following sentence using print function. you must print the double cotation of the sentences.
"Honesty is the best policy"


In [42]:
print('"Honesty is the best policy"')

"Honesty is the best policy"

9. Print this sentence = "i like 'fish' and 'egg' but i haven't money to buy."


In [43]:
print("i like 'fish' and 'egg' but i haven't money to buy.")


i like 'fish' and 'egg' but i haven't money to buy.

10. Write a code that represent all the systex of Lecture 2.2. You can use any kind of example.


In [46]:
#input function-single input
a=input("what is a?")
print(a)
​a=float(input("what is a?"))
print(a)
​#input function-multiple input
b, c=input("What is b & c? Enter 'SPACE' after each").split()
print(b, c)
#Using map function to input variable
a, b, c=map(float, input("Enter three Float numbers here! Press'SPACE'after finsihing each number").split())
print(a, b, c)

what is a?5
5
what is a?7
7.0
What is b & c? Enter 'SPACE' after each10 20
10 20
Enter three Float numbers here! Press'SPACE'after finsihing each number10.1 20.2 30.3
10.1 20.2 30.3

md.mokshedurrahman
Автор

Sir, I'm facing a problem with this question: Print this sentence = "i like 'fish' and 'egg' but i haven't money to buy." Could you please help?

PrepPro_BD
Автор

print(A, end=' ') এখানে স্পেসের বদলে নিউ লাইন দিতে পারি কি ?

nayeemreaz
Автор

কোডে লিখার পরে রান করার পর ওই কোড টা আবার মডিফাই করার পরে আর রান হয়না।। 😪

syedmosiurrahamankiron
Автор

Assignment_2 porblem solution.

#1 Take three numbers as input and find the sum of them.
num_1, num_2, num_3 = map(int, input("Please Enter the Three number for sumation: ").split())
sum = num_1+num_2+num_3
print("The number sumation of %d, %d and %d is %d"%(num_1, num_2, num_3, sum))

#2 Take the radious of a circle as input and find the area of the circle. Answer should be 3 decimal point
radious = float(input("Please Enter the radious of circle: "))
pi=float(3.1416)
area = pi*radious**2
print("The radious %.3f of a circle's area is %.3f"%(radious, area))

#3 Take two number as input by one input function and calculate their addition, subtraction, multiplication and division
num_1, num_2 = map(float, input("Please Enter the two integer naumber: ").split())

sum = num_1 + num_2
dif = num_1 - num_2
mult = num_1 * num_2
dev = num_1 / num_2

print("There are four section addition= %.2f, subtraction= %.2f, multiplication= %.2f and devision= %.2f"%(sum, dif, mult, dev))

#4 Input 3 float numbers and find their average and print like this. "the average of a, b and c is d", use any output formating
num_1, num_2, num_3 = map(float, input("Please Enter the two integer naumber: ").split())
ave = (num_1+num_2+num_3)/3
print("The average of {0}, {1} and {2} is {3}".format(num_1, num_2, num_3, ave))

#5 Take 3 integer and 3 float number and find the difference between the integers and floats.
num_1, num_2, num_3 = map(int, input("Please Enter the Three integer number: ").split())
num_4, num_5, num_6 = map(float, input("Please Enter the Three float number: ").split())
dif_1=num_1 -num_4
dif_2=num_2- num_5
dif_3=num_3 -num_6
print("The integer number %d and float number %.2f difference is %.2f"%(num_1, num_4, dif_1))
print("The integer number %d and float number %.2f difference is %.2f"%(num_2, num_5, dif_2))
print("The integer number %d and float number %.2f difference is %.2f"%(num_3, num_6, dif_3))

#6 Input three string by one input function and make a sentence using the three string.
str_1, str_2, str_3 =map(str, input("Please Enter the three string : ").split())
print("This is the sentence which that you input: %s %s %s."%(str_1, str_2, str_3))


#7 input 2 number as string, convert them to number, find their sum then convert the sum to string and print using format specifier.
str_1, str_2 =map(str, input("Please Enter the two number as string : ").split())
num_1 =int(str_1)
num_2 =int(str_2)
sum =num_1+ num_2
Sum =str(sum)
print("There are two number as string {0} and {1} their sumation is {2}".format(num_1, num_2, Sum))

#8 Print the following sentence using print function. you must print the double cotation of the sentences
proverb = '"Honesty is the best policy"'
print(proverb)

#9 Print this sentence = "i like 'fish' and 'egg' but i haven't money to buy."
sentence = "i like \'fish\' and \'egg\' but i haven't money to buy."
print(sentence)

Problem_10 I can't understand.

sajibahamed