Exercise 2 solution : Python tutorial 124

preview_player
Показать описание
Guys please help this channel to reach 20,000 subscribers. I'll keep uploading quality content for you.

Python is easy programming language to learn and anyone can learn it, and these tutorials are 100% free in hindi.

You can share this playlist with your brother, sisters and friends. This will surely add some values to their life.

If you follow this complete playlist of python tutorial surely you will learn everything about python programming language.

This is solution of exercise 2 chapter 7

Рекомендации по теме
Комментарии
Автор

Solution :

example = dict.fromkeys(["name", "age", "fav_movies", "fav_songs"], "unknown")

for i in example:
example[i] = input(f" Please Enter Your {i}, Comma Separeted : ").split(", ")

for i, j in example.items():
print(i, j)

#The name and age are also in list when output, as I'm using split() method to input all the values using a loop.

Thanks alot sir, by your videos I'm able to think of the solution by my own :) Keep up the good work

NoorMuhammad-dtkf
Автор

Sir after completing total python... Please sir make few big useful projects/softwares so we will understand real life applications.. 🙏🙏..

chinmaydas
Автор

Thanks a lot SIR, Its my 3rd day with this course and this is how i am doing>>

d=dict.fromkeys("Name Class Rollno fav_movie School".split(), 'unknown')
for i in d:
d[i]=input(f"What is your {i} ").split()
for key, value in d.items():
print(f"{key} : {value}")

vinuboora
Автор

@harshit vashisth bhai u r d best and evergreen

SaurabhKumar-nwgu
Автор

Hello Harshit,

All the tutorials are really good
Thanks for sharing your valuable knowledge to us.

Here is the solution I tried, which gives me a same result.
Please have a look and let me know your feedback.

user_info = {
'name': input("Enter the name: "),
'age' : int(input("Enter the age: ")),

'fav_movies' : input("Enter the name of movie: ").split(', '),
'fav_tunes' : input("Enter the name of songs: ").split(', '),
}



for key, value in user_info.items():
print(f"{key} : {value}")

pradeeppal
Автор

Sir apne bahot ache se samjaya hai ek ek chiz

bhaveshmevada
Автор

sir if you see this comment then please please please reply me. I am your great Fan

kavyagandhi
Автор

Sir hm key b to user se input krwa sakte h for loop lgakr

arpitgupta
Автор

# Episode 123

data={}

data['name']=input("Enter Your name:- ")
data['age']=int(input("Enter your age:- "))
your fav movies separated by, :-").split(', ')
your fav songs separated by, :- ").split(', ')

for key, value in data.items():
print(f"{key} = {value}")

gauravmarathe
Автор

def print_dictionary(d):
for i in d:
print (d[i])
this also works for printing keys in individual lines

tejsisharma
Автор

How did movies and songs got printed as list ?

hariprasadr
Автор

Sir how fav movies and fav songs are automatically stored lists, but not name and age.. We did nothing different., then why movies and songs are stored in List automatically???

mitadey
Автор

is program ma aik problem arahi ha jab print kro tou woh dictionary ka ander nahi print hota, simple print ho rha ha jaisa ap ka print hoa ha

hamadshigri
Автор

*#code**:-*
user_info={
"name":input("enter your name:")
"age":int(input("enter your age:")
"favS":list(input("enter your favorite songs by comma saperated:").split(", ")
"favM":list(input("enter your favorite movies by comma saperated:").split(", ")
}
for i, j in user_info.itemes():
print(f"{i} : {j}")
*#output**:-*
enter your name: zahid
enter your age:18
enter your favorite songs by comma saperated:Perfect, Believer
enter your favorite movies:Iron man 1, Thor ragnarock
name : zahid
age : 18
favS : [Perfect, Believer]
favM : [Iron man 1, Thor ragnarock]

MuhammadZahid-qoof
Автор

info={}
while True:
n=input("you have any key(yes/no):")
if n=="yes":
x=input("enter the key:")
y=input("enter the value:")
info[x]=y
else :
break
for i in info:
print(f"{i}:{info[i]}")

#this code is create number of keys and their values

nikhilpatil
Автор

Bro code input in the empty dictionary. Means we use do this
User = { 'name' : input (" Enter the name),
'Age': input (" Age :")
}
Print(user)

salilchandan
Автор

Ur good python tutor, how can I expert in python

aksingh
Автор

another solution:
list = ['name', 'age', 'favourite movies', 'favourite songs']
def fun(l):
d ={}
for i in l:
print (f'enter your {i} : ', end = " ")
j = input()
d[i] = j
for i, j in d.items():
print (f'{i} : {j}')
fun(list)

soyeb
Автор

Jo fav_song and movie h use jb dictionary m add kiya to automatically list m kse convert ho gya?

Virgo
Автор

# taking input from and storing into variable
def user_input(name, age, favourite_movie, favourite_song):
inputted={}
for i in name, age, favourite_movie, favourite_song:
inputted["name"]= name
inputted["age"]=age
inputted["favourite movie"]= favourite_movie
inputted["favourite song"]= favourite_song
return inputted
print(user_input(input("whats your name: "), int(input("whats your age: ")), input("enter your favourite movie:"), input("whats your fabourite song:")))
# did it auccessfully

dogbrosinc