f-strings in Python | Python Tutorial - Day #28
Вставка
- Опубліковано 11 вер 2024
- Python is one of the most demanded programming languages in the job market. Surprisingly, it is equally easy to learn and master Python. This python tutorial for absolute beginners in Hindi series will focus on teaching you python concepts from the ground up.
Access the Playlist: • Python for Beginners (...
Link to the Repl: replit.com/@co...
Join Replit the browser-based IDE used in this course - join.replit.co...
►Checkout my English channel here: / @programmingwithharry
►Instagram: codewithharry
python, C, C++, Java, JavaScript and Other Cheetsheets [++]:
Playlist: • Coding CheatSheets 🧾 b...
►Learn in One Video[++]:
Python[15 Hr]: • Python Tutorial For Be...
Python Advance[3.5 Hr]: • Python Programming Cou...
Python[1 Hr]: • Learn Python In Hindi ...
Python[2 Hr]: • Python Tutorial In Hin...
Python[15 Min]: • 15 Minute Python Tutor...
JavaScript[1 Hr]: • JavaScript Tutorial
C[1.3 Hr]- • C Programming Tutorial...
php[1 Hr]: • Learn Php In One Video...
php[2.3 Hr]: • Php Tutorial for Begin...
php[Project]- • Login And Registration...
HTML[30 Min]: • HTML 5 Tutorial For Be...
CSS[8.5 Hr]: • CSS Tutorial In Hindi ...
CSS[1.4 Hr]: • CSS 3 Tutorial For Beg...
Wordpress[3.2 Hr]: • How To Make a WordPres...
Angular[2 Hr]: • Angular Tutorial in Hindi
Java[2.3 Hr]: • Java tutorial in hindi 🔥
Web Scraping[1 Hr]: • Web Scraping Tutorial ...
MongoDB[2 Hr]: • MongoDb Tutorial For B...
Numpy[1 Hr]: • Numpy Tutorial in Hindi
Android Dev[12 Hr]- • Android Development Tu...
Linux[1 Hr]: • Linux Tutorial For Beg...
JQuery[1.1 Hr]: • jQuery Tutorial For Be...
Git and GitHub[1.1 Hr]: • Git & GitHub Tutorial ...
►Complete course [playlist]:
React: • React Js Tutorials in ...
Python- • Python Tutorials For A...
OOP Python- • Object Oriented Progra...
Java: • Java Tutorials For Beg...
JavaScript- • JavaScript Tutorials I...
PHP- • PHP Tutorials in Hindi
C- • C Language Tutorials I...
C++- • C++ Tutorials In Hindi
Git & GitHub- • Git and GitHub Tutoria...
Android Dev- • Android Development Tu...
Python GUI- • Python GUI: Tkinter Tu...
Web Development- • Web Development Tutori...
Python Django: • Python Django Tutorial...
Projects Using HTML, CSS & Javascript- • Projects Using HTML, C...
Data Structure and Algo: • Data Structures and Al...
Follow Me On Social Media
►Website (created using Django Rest & Angular): www.codewithha...
►Facebook: / codewithharry
►Instagram: / codewithharry
Twitter: / codewithharry
Comment "#HarryBhai" if you read this 😉😉
🎉Merry Christmas to all python learners🎉
same to u bhaiya
thanks
our gift is this 100 day course
Happy Tulsi Diwash to all of you
Thank you.
Same to you bhaiya
Aapko bhi bhaiya ji
7:46
You can print it as it is without writing f before double quotes like this:
print("We use f-strings like this: Hey my name is {name} and I am from {country}")
The output will be same as:
print(f"We use f-strings like this: Hey my name is {{name}} and I am from {{country}}")
Yeah exactly bro.
❤
Yes you are right but Harry is trying to show that how to print along with curly brackets while using f-strings.😃
Day6 of #100DaysOfCode. Today in this video 28, I learned about string formatting in Python using the format method and f-strings. The format method allows for more precise control over the formatting, such as specifying the number of decimal places. F-strings, introduced in PEP 498, provide a convenient way to embed Python expressions directly inside string literals for formatting. By prefixing a string with 'f', it becomes an f-string, making it easier to interpolate variables and expressions.
Thank You Harry Bhaiya.
bro did you complete the course or not?
"This Python Course is Helpful"
-Who remember This Line of Harrry Sir
Meeeeeeee3ee!!!
7:37 But Harry Bhai, if we want to print the string as it is without replacing the identifiers with corresponding values, we could simply remove that *"f"* before the string which will turn the f-string into a normal string
I thought of the same
but in real programs you have to use f string generally with those {} brackets in use also so that is why it is helpful
7:43
to show as it is just remove f
print(f"hey my name is {name} and i am form {country}")
like this
print("hey my name is {name} and i am form {country}")
f-strings are quite like Template Literals of JavaScript
Yeah 😊
thats what i was thinking
whoooooooooooooooo ⚜
Bahoot jyada
Me also
Haa ye krlo pehle 😄
Bro even I am 😭
@@levi-07 keyboard vi thanda lag raha hai😂😂😂😂😂😂
Jo sab log paise lekar bhi nahi sikhte
Vo Harry Bhai free me sikha rahe he
Keep it harry Bhai
And guys please share harry bhai's chanale as well as posible.
Practice Questions for this exercise:
1. Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
2. Write a program that calculates the area of a rectangle. Prompt the user for the length and width, then display the result using an f-string.
3. Develop a simple currency converter program. Ask the user for an amount in USD and convert it to euros using a fixed conversion rate. Display the result using an f-string.
thanks,
faceSense
where i can get more problems like these?
You can provide solution???
1.Answer
name = input("Enter your name: ")
age = int(input("Enter your age: "))
print(f"{name} will turn 100 years in {100 - age}")
base = float(input("Enter base: "))
height = float(input("Enter height: "))
Area_Of_Rectangle = base * height
print(f"Area of rectangle is: {Area_Of_Rectangle} ")
dollar_amount = float(input("Enter amount in dollars: "))
conversion_rate = 0.92
euro_amount = dollar_amount * conversion_rate
print(f"The converted amount is: €{euro_amount:2f}")
@@navneetpathrabe9484 hlo i want to print my name and my frnd name for 3 time if it above three time then loop will b terminated how i can solv
I listened about this channel from a multi millionair stock trader of DELHI. then i seached this. and by GOD's grace i recalled my old days of 2003 when i learned my C, C++, C# from NIIT.
#Day28
#100DaysOfCode
No day missed yet.
question = ["Which country has largest army in the world ?" ,"Which country has fastest growing economy in the world","Which country has maximum number of time zones? "]
answer = ["China","India","Russia"]
que1 = print(question[0])
ans1 = input()
if ans1 == answer[0] :
print("Your answer is correct you have won 10,00,000 rupees")
que2 = print(question[1])
ans2 = input()
if ans2 == answer[1]:
print("Your answer is correct you won 1,00,00,000 rupees")
que3 = print(question[2])
ans3 = input()
if ans3 == answer[2]:
print("You won the game and you earn 7,00,00,000 rupees")
else :
print("Sorry you loss the game")
else:
print("Sorry you have earn zero rupees and you disqualified ")
else:
print("Sorry you have earn zero rupees and you disqualified ")
Thankyou sir... I'm doing this course in April and my aim is to complete 10 videos everyday to get this course done in 10 days... it's the 3rd day and I'm just 2 videos away from today's goal... thank you so much sir this course is so helpful and I can imagine how much I will be changed after the completion of this course regarding my programming skills...again thank you ❤️❤️
Mera bhi aisa same goal tha lekin ab me 20-30 aik din me kar raha hoon
@@PHros good bro
finished?
@@TopRTelugu unfortunately no bro.. i was busy in doing college things.. I'll continue soon after my sessionals get over.. it's a vast thing and so it is important to learn all modules separately.. first build basic understanding of all modules and then take lectures and then practice for better results.. reply on this comment when you complete the whole course.. good luck
Present sir 😁
After a trip of 1 week I got 7 backlogs in this program....
Backlog 4/7 completed
intresting
a=int(input("enter the hour"))
if a==0 and a
Good 💯 your code is correct!!
One of the most Underrated Channels out there!!
Harry sir please make a video about ChatGPT. How to use ChatGPT for earning purpose
Present Sir on Day-28 ✋✋
Day 28 done ✅
#Harrybhai
One day I'll definitely meet you bhai 🤘
Day -28 Done
Day #17 of asking to make a discord server.
00:01 Python provides string formatting to place variables inside strings conveniently.
01:07 Using f-strings to format strings in Python.
02:16 f-strings in Python for easy and convenient string formatting
03:08 Python f-strings allow easy string formatting with variables.
04:10 Formatting floating point numbers with f-strings.
05:24 F-strings allow easy formatting of strings with variables
06:37 Using f-strings to insert variables into strings
07:36 Using double curly brackets to display curly brackets in f-strings.
Crafted by Merlin AI.
Day 28✨
merry Christmas harry bhai🎅🎅
Hello Bhai mera question ye h ki majority mere friends k pss window laptop h... Me MacBook lena chahta hu but dikkat ye h ki window and MacBook me connectivity me issues naa aaye kahi data share yaa kuch orr process me 🤔🤔🤔 plzz bhai is topic par video bana do and sare MacBook ko compare karke konsa kiske liye sahi rahega bataiye 🙏🙏🙏
Just used f strings in previous exercise
Same here
#Day28
#Present
#CodeWithHarry
#PythonChallenge
Watching after 1 day
...was busy because of school exam preparation.
LOVE YOU HARRY BHAI❤
day 28 completado stoico
Best topic fstrings
The thing I want in c++ so much
Day 28 🔥
Imagine getting ultimate course Web development 2023🤦🏻🥰
?
@@vaibhavnayak3416 what?
How To code in python ATM Machine ??
Harry bhaiii please kivymd ka tutorial
Great Going Coding Ka Rang Chad Gaya He Ekdum
Sir please kivy & kivymd tutorial
28th one!!
Please make a course on unity too
BRo he is mainly Focused on web dev and high level programming languages. Check out bRackeyes course on yt
Python is best programming language
#day28 merry Christmas harry bhai🎅🎅
Sir still old method of string formatting is used. Is it important ?
Day #28 in 100DaysOfCode. Thanks, harry bhai for this Christmas gift(100DaysOfCode).
You deserve the best in Life!!
It is in the JS also but by string literals name
#Day28 Present Sir
Completed day#28 challenge...😍
Bhaiya do baar curly braces na dekar f ko hata dene se hi toh ho jayega. Fir 2 baar curly braces q?
#harryBhai is course me hm jarvaiz type kch bnayn gy. At the end ? 🤔🤔🤔
Day 28 of Coding. Present Sir.
Harry bhai ye program run n ho rha hai Mera help kro do
harry bhai turtle module bhi sikhaoge kya??
Please start the data science course.
Guys just a question are curly brackets necessary for f string?
Yes
day 28 done
day 28 present sir
Sir please tell us what is problem in this code"
a = 4
print("%a"%a)
print("%c"%a)
print("%d"%a)
print("%e"%a)
print("%f"%a)
print("%g"%a)"
💖 Merry ⛄ Christmas 💖⛄ Bro 😘
f-string work like a string literal in JavaScript
Sir artificial intelligence course bhi launch kar dem
Present ! Day 28
8:00
string ko as it is show karne ke liye string se pehele wale f ko bhi to hata sakte hai na?
#Day28
In this video 8:20 time we can also delete the 'f' outside the double quotes to show calibrates with the parameter name, like
print("My name is {name} and I am from {country}")
yup, thats what i thought too !!!
Beside printing {something}, what if you also want to print a variable in the same string?
i.e.
name = "Random"
print (f"My name is {name} and I'm from {{country}}")
In this case, you just can't remove f" " cuz you want to print {name} too.
present sir
Day 28 done!
Present sir
Day 28 of 100 days of code
Pranam bhrata 🙏 apka bahutt baht dhanyawad ❤️😌🙏😇🧡💛😇
Present Sir 🤚
Great Harry bhai
Majja aa raha hai harry bhai
Python se to pyaar sa hogya hai
Thanks a lot Sir!!
Apple macbook m1 abhi lena chahiye kya pls reply
print(f"{2 * 30}")
Guys iss code m No. Ko int() define nhi kiya code m to ,python isse as a string smghega ,lekin value kaise mil ja rha h 60 jbki wo isse as a string consider kar rha h?
Kya f string m hmme int batane ki jaroorat nhi h ,(Double cot) string m python ko show karna k liye?
Present from Bangladesh Brother.....#day28 Done
Day #28
Why need to print example of f-string inside f-string. simply remove f of begining. I printed this - This is how to create F-String: write variable name inside curly bracket like {variable-name} and put a f at begining. For example, f"my name is {firstName} {lastName}" using this - print('This is how to create F-String: write variable name inside curly bracket like {variable-name} and put a f at begining. For example, f"my name is {firstName} {lastName}"' )
Present Harry Sir!
making Kbc execise was fun
Day_28 Present Sir
I create it Because for solving doubts
print("Welcome ladies and gentlemen to Kaun Banega Crorepati
first question for 7 crore on your computer screen is ")
q = ["How many colours are there in a rainbow?","(a)2 (b)5 (c)7 (d)8"]
print(q)
a = str(input("Enter the correct answer = "))
ans1 = "c"
ans2 = "7"
ans3 = "seven"
ans4 = "Seven"
ans5 = "C"
if (a== ans1 or a==ans2 or a==ans3 or a==ans4 or a==ans5) :
print("Congratulations!,You win 7 crore.")
else :
print("Sorry answer is wrong.")
Replit ki new policy ki wjah se or repls create nhi ho rhi :(
In f_string there is not given the value of {Name,Country}
#DAY28 COMPLETED
THANK YOU #CodeWithHarry
Bhaiya web 3.0 ka full stack developer course lao please ya iske bare me ek acha sa roadmap video banado....
Kya baat hai guru jii
I'm present.
Present sir 🤚
First line ka {0} dusre line mai kaise kiya please bataua
Thanks bhaiya ❤
Day28-PRESENT SIR!
superb brother
Question = ("What is the capital city of Nepal")
O1 = ("Kathmandu")
O2= ("Pokhera")
O3 = ("Jhapa")
O4 = ("Nepaljung")
option = [O1, O2, O3, O4,]
print(option)
money = 000
add = money + 1000
answer = O1
if answer in option:
print("yes,You won the NRs 1000")
print("Your total money is :", add)
else:
print("No, You lose money")
Practice Questions for this exercise:
1. Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old.
2. Write a program that calculates the area of a rectangle. Prompt the user for the length and width, then display the result using an f-string.
3. Develop a simple currency converter program. Ask the user for an amount in USD and convert it to euros using a fixed conversion rate. Display the result using an f-string.
@@FaceSenseAustralia !✨🤩
Day #28 done
Present Sir, Done!!
Happy festive season
8:16 we can simply remove f from the starting🤣😂