8000 updated! · sru0309/python_practices@7faed06 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 7faed06

Browse files
committed
updated!
1 parent bf724db commit 7faed06

File tree

1 file changed

+133
-0
lines changed

1 file changed

+133
-0
lines changed

002-basic-string-program.ipynb

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,139 @@
474474
"print(\"string after:\",res)"
475475
]
476476
},
477+
{
478+
"cell_type": "markdown",
479+
"metadata": {},
480+
"source": [
481+
"- program to cheak if a string has at least one letter and one number"
482+
]
483+
},
484+
{
485+
"cell_type": "code",
486+
"execution_count": 2,
487+
"metadata": {},
488+
"outputs": [
489+
{
490+
"name": "stdout",
491+
"output_type": "stream",
492+
"text": [
493+
"True\n",
494+
"False\n"
495+
]
496+
}
497+
],
498+
"source": [
499+
"def cheakstring(str):\n",
500+
" flag_l = False\n",
501+
" flag_n = False\n",
502+
"\n",
503+
" for i in str:\n",
504+
" if i.isalpha():\n",
505+
" flag_l = True\n",
506+
" if i.isdigit():\n",
507+
" flag_n = True\n",
508+
" return flag_l and flag_n\n",
509+
"print(cheakstring(\"they 2 are busy \"))\n",
510+
"print(cheakstring(\"hey there\"))\n"
511+
]
512+
},
513+
{
514+
"cell_type": "code",
515+
"execution_count": 4,
516+
"metadata": {},
517+
"outputs": [
518+
{
519+
"name": "stdout",
520+
"output_type": "stream",
521+
"text": [
522+
"True\n"
523+
]
524+
}
525+
],
526+
"source": [
527+
"def cheakstring(str):\n",
528+
" flag_l = False\n",
529+
" for i in str:\n",
530+
" if i.isalpha():\n",
531+
" flag_l = True\n",
532+
" if i.isdigit():\n",
533+
" flag_l= True\n",
534+
" return flag_l\n",
535+
"print(cheakstring(\"hey there3\")) "
536+
]
537+
},
538+
{
539+
"cell_type": "code",
540+
"execution_count": 8,
541+
"metadata": {},
542+
"outputs": [
543+
{
544+
"name": "stdout",
545+
"output_type": "stream",
546+
"text": [
547+
"False\n"
548+
]
549+
}
550+
],
551+
"source": [
552+
"def cheakstring(str):\n",
553+
" for i in str:\n",
554+
" if i.isdigit():\n",
555+
" flag_l =True\n",
556+
" else:\n",
557+
" flag_l = False\n",
558+
" return flag_l\n",
559+
"print(cheakstring(\"hey there\"))"
560+
]
561+
},
562+
{
563+
"cell_type": "code",
564+
"execution_count": 11,
565+
"metadata": {},
566+
"outputs": [
567+
{
568+
"name": "stdout",
569+
"output_type": "stream",
570+
"text": [
571+
"False\n"
572+
]
573+
}
574+
],
575+
"source": [
576+
"def chaekstring(str):\n",
577+
" for i in str:\n",
578+
" if i.isalpha():\n",
579+
" flag_n=True\n",
580+
" else:\n",
581+
" flag_n= False\n",
582+
" return flag_n\n",
583+
"print(cheakstring(\"hey there \"))"
584+
]
585+
},
586+
{
587+
"cell_type": "code",
588+
"execution_count": 1,
589+
"metadata": {},
590+
"outputs": [],
591+
"source": [
592+
"def cheak(string):\n",
593+
" string=string.lower()\n",
594+
" vowel_1 =set('aeiou')\n",
595+
" string_1= set({})\n",
596+
" for character_1 in string:\n",
597+
" if character_1 in vowel_1:\n",
598+
" string_1.add(charcter_1)\n",
599+
" else:\n",
600+
" pass\n&q 7C4E uot;,
601+
"\n",
602+
" if len(string_1)==len(vowel_1):\n",
603+
" print(\"the string is accepted\")\n",
604+
" else:\n",
605+
" print(\"the string is not accepted\")\n",
606+
" \n",
607+
" "
608+
]
609+
},
477610
{
478611
"cell_type": "code",
479612
"execution_count": null,

0 commit comments

Comments
 (0)
0