You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Solution Can be of question 14:
string=input("Enter the sentense")
upper=0
lower=0
for x in string:
if x.isupper()==True:
upper+=1
if x.islower()==True:
lower+=1
Solution Can be of question 14:
string=input("Enter the sentense")
upper=0
lower=0
for x in string:
if x.isupper()==True:
upper+=1
if x.islower()==True:
lower+=1
In python, while printing a dynamic value inside a string, there are several ways to format the output string. For example, let's say you have two variables a = 10 and b = 20 and you want to output something like this,
The sum of 10 and 20 is 30
You can do this by writing it in this way,
print("The sum of {0} and {1} is {2}".format(a, b, a + b))
Here 0, 1, 2 inside '{ }' represents the order of a, b and a+b respectively.
However, If the code is written in this way,
print("The sum of {1} and {0} is {2}".format(a, b, a + b))
then the output will be like,
The sum of 20 and 10 is 30
But printing in this way is not very much necessary. It can be also written in this way,
print("The sum of {} and {} is {}".format(a, b, a + b))
which will give the same output as wanted. I was new to python at that timeline so that I learned and used in {0}, {1} style which is actually not mandatory at all.
Activity
[-]Question, Discussion & Bug Report[/-][+]Query, Discussion & Bug Report[/+]Amitewu commentedon Apr 16, 2019
Solution Can be of question 14:
string=input("Enter the sentense")
upper=0
lower=0
for x in string:
if x.isupper()==True:
upper+=1
if x.islower()==True:
lower+=1
print("UPPER CASE: ",upper)
print("LOWER CASE: ",lower)
darkprinx commentedon Apr 17, 2019
Added. Thank you :)
Amitewu commentedon Apr 19, 2019
In problem 17 How do I terminate this while true condition?????
darkprinx commentedon Apr 19, 2019
Just check whether the input is empty or not.
sam1037 commentedon Jul 22, 2019
In answer 14, your solution 2, what is '{0}' and '{1}'? I don't understand.
darkprinx commentedon Jul 22, 2019
In python, while printing a dynamic value inside a string, there are several ways to format the output string. For example, let's say you have two variables a = 10 and b = 20 and you want to output something like this,
The sum of 10 and 20 is 30
You can do this by writing it in this way,
print("The sum of {0} and {1} is {2}".format(a, b, a + b))
Here 0, 1, 2 inside '{ }' represents the order of a, b and a+b respectively.
However, If the code is written in this way,
print("The sum of {1} and {0} is {2}".format(a, b, a + b))
then the output will be like,
The sum of 20 and 10 is 30
But printing in this way is not very much necessary. It can be also written in this way,
print("The sum of {} and {} is {}".format(a, b, a + b))
which will give the same output as wanted. I was new to python at that timeline so that I learned and used in {0}, {1} style which is actually not mandatory at all.
Thank you :)
sam1037 commentedon Jul 23, 2019
Thank you for teaching me.
Amitewu commentedon Jul 29, 2019
#This could be the ans for 16
x=input().split(",")
ans=list(filter(lambda x : int(x)%2!=0 ,x))
print(",".join(ans))
darkprinx commentedon Jul 29, 2019
Added to question# 16
ArturOle commentedon Sep 17, 2019
Question 38 ans proposition:
tup = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
lt = int(len(tup)/2)
print(tup[:lt], tup[lt:])
208 remaining items