Skip to content

Commit eccf6bf

Browse files
authored
Add files via upload
1 parent 6534d7f commit eccf6bf

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
variables
2+
=========
3+
>>> first="Tom"
4+
>>> middle="Cruise"
5+
>>> last="Mapother"
6+
>>> print("Full Name:",first,middle,last)
7+
Full Name: Tom Cruise Mapother
8+
9+
numbers
10+
=======
11+
(1) Find out an area of a triangle whose base is 15 meter and height is 22 meter. The mathematical equation for an area of a triangle is: Area = ½*Base*Height
12+
>>> base=15
13+
>>> height=22
14+
>>> area=1/2*(base*height)
15+
>>> area
16+
165.0
17+
18+
(2) You bought 9 packets of potato chips from a store. Each packet costs 1.49 dollar and you gave shopkeeper 20 dollar. Find out using python, how many dollars is the shopkeeper going to give you back?
19+
>>> num_packets=9
20+
>>> cost_per_packet=1.49
21+
>>> total_cost=num_packets*cost_per_packet
22+
>>> money_paid=20
23+
>>> cash_back=money_paid-total_cost
24+
>>> cash_back
25+
6.59
26+
27+
(3) The bathroom of your home is an exact square. You want to replace tiles in it. Length of this bathroom is 5.5 feet. How many square foot of tiles you need to buy? Equation for an area of a square is: Area = Length to the power of 2. Find it out using python.
28+
>>> length=5.5
29+
>>> area=length**2
30+
>>> area
31+
30.25
32+
33+
strings
34+
=======
35+
(1) Create a string variable to store this text "Earth revolves around the sun",
36+
(a) Print substringrevolves
37+
(b) Print substringsunusing negative index
38+
>>> s="Earth revolves around the sun"
39+
>>> s[6:14]
40+
'revolves'
41+
>>> s[-3:]
42+
'sun'
43+
(2) Create a string variable to store this text "Earth revolves around the “sun”" and print it
44+
>>> s='Earth revolves around the “sun”'
45+
>>> s
46+
'Earth revolves around the “sun”'
47+
(3) Create three string variables with valuesI love eating“, “veggies”, “fruits
48+
(a) PrintI love eating veggies and fruits” (Hint: Use + operator)
49+
>>> s1="I love eating"
50+
>>> s2="veggies"
51+
>>> s3="fruits"
52+
>>> s1+" " +s2+" and "+s3
53+
'I love eating veggies and fruits'
54+
(b) Create fourth variable to store number of fruits you eat everyday. Say for example you eat 2 fruits everyday, in that case printI love eating 2 fruits everyday
55+
>>> num_fruits=2
56+
>>> s1+" "+str(num_fruits)+" "+s3+" everyday"
57+
'I love eating 2 fruits everyday'

0 commit comments

Comments
 (0)